We are Web Technology Experts Team who provide you Important information on Web Development, Interview Questions and Answers, live project problem and their solution and online free tutorials.
Showing posts with label PHP Interviews Questions. Show all posts
Showing posts with label PHP Interviews Questions. Show all posts
Friday 9 January 2015
Monday 5 January 2015
Difference between Notice and warning and fatal error
Notice
- A notice is an advisory message like "You probably shouldn't be doing what you're doing"
- Execution of the script is not halted
- Example
echo $undefinedVariable;
Warning
- A warning is a message like "You are doing something wrong and it is very likely to cause errors in the future, so please fix it." Execution of the script is not halted;
- Example
echo 1/0;
Fatal Error
- Fatal run-time errors
- Execution of the script is not halted
- Example
require_once "notexistfile.php"
Best Related Posts are Following:
- What are differences between $(document).ready and $(window).load?.
- Difference between MVC and MVP design pattern.
- What is difference between event.preventDefault() and return false in Javascript?.
- What is the difference between call and apply in javascript?.
- Difference between inner join and outer join in MySQL.
- Difference between theme and template in website.
- Difference between in_array and array_key_exists in php with Example.
- Difference between SSL and HTTPS.
- Difference between Notice and warning and fatal error.
- Difference between overloading and overriding in php with Example.
- What is difference between natcasesort and sort?.
- Difference Between Hadoop and Big-Data.
- Difference Between Primary Key And Unique Key And Foreign Key And Composite Key.
- PHP Sessions and Cookie and Security.
- Difference between WebService and API.
- Difference Between MyISAM and innoDB - MySQL.
- Difference Between Zend framework 2 VS Zend framework 1.
- Difference between JSON and JSONP.
- Difference Between Cakephp and Zend Framework.
- Difference between Abstract class and Interface in PHP.
Sunday 14 December 2014
Object Oriented Programming in PHP
Following concept are used in Object Oriented Programming in PHP.
- Introduction
- The Basics
- Properties
- Class Constants
- Autoloading Classes
- Constructors and Destructors
- Visibility
- Object Inheritance
- Scope Resolution Operator (::)
- Static Keyword
- Class Abstraction
- Object Interfaces
- Traits
- Overloading
- Object Iteration
- Magic Methods
- Final Keyword
- Object Cloning
- Comparing Objects
- Type Hinting
- Late Static Bindings
- Objects and references
- Object Serialization
- OOP Changelog
Best Related Posts are Following:
- How to Detect Request type (GET OR Post ) in PHP.
- PHP Basic questions and answers for fresher and experienced.
- PHP Mysql Interview Questions and Answers for fresher and experienced.
- PHP interview questions and answers for 5 year experienced.
- PHP Frequently asked Questions and Answer 2015.
- PHP problem solving interview questions and answers for Fresher and Experienced.
- PHP Interview Questions and Answers for 2 year Experience.
- What is stdClass? and How to create stdClass class?.
- Advanced PHP Interview Questions and Answers.
- SPDY Protocol - Improve the Speed of web page.
- PHP Technical Interview Questions and Answers for Fresher and Experienced.
- How to stop parsing the HTML tags?.
- Difference between Notice and warning and fatal error.
- Node Js Interview Questions and Answers for Experienced.
- Object Oriented Programming in PHP.
- Htaccess RewriteRule Flags by Code Example.
- Enabling the openssl in Wamp-Xampp.
- How to find day of week in php in a specific timezone.
- What is difference between natcasesort and sort?.
- Zend Cache Tutorial - Zend Framework 1.12.
- Nginx Server interview Questions and Answers.
- XML Interview Questions And Answers.
- Important PHP Interview Questions and Answers - jQuery, SQL Modes, Client Programs and Reset.
- PHP Check Mime Type of File - Return Information About A File.
- Improve Ajax Performance.
- PHP Captcha Code Example Code Snippets.
- PHP - Secure Ajax Call from Hackers - Example.
- Zend Database Query - Zend Profiler Example - Code Snippets.
- Export to CSV File - PHP.
- htaccess code snippets example.
- Manage Cron Job with PHP - SSH2 Connection.
- OOP Interview Questions and Answers.
- CURL Example.
- PHP Interview Questions and Answers PDF.
- Stored Procedure - Advantage of Stored Procedure - Disadvantage of Stored Procedure.
Wednesday 10 December 2014
Htaccess RewriteRule Flags by Code Example
A RewriteRule can be modified by flag. Flags are included in square brackets at the end of the rule. We can also and multiple flags are separated by commas.
For Example:
[Flag1] //for 1 flag [Flag1,Flag2] //for 2 flags [Flag1,Flag2,Flag3 ] //for multiple flags
Following are most commonly htaccess flag:
1. htacces B(escape backreferences) Flag
Escape non-alphanumeric characters before applying the transformation
2. htaccess C(Chain) Flag
First htaccess Rule will be applied to next htaccess rule. Means if the rule matches, then control moves on to the next rule.
3. htaccess CO(Cookie) Flag
you can set a cookie when a particular RewriteRule matches
RewriteRule ^search/(.*)$ /search.php?term=$1[CO=variable:variableValue]Set the variable=variableValue in cookie
4. htaccess DPI(discardpath) Flag
PATH_INFO portion of the rewritten URI to be discarded.
5. htaccess E (env) Flag
You can set the value of an environment variable. For example:
RewriteRule ^search/(.*)$ /search.php?term=$1[E=variable:variableValue]Set the variable=variableValue in environment variable.
6. htaccess END Flag
This flag terminates not only the current round of rewrite but also prevents any subsequent rewrite from occurring in per-directory.
7. htaccess F(forbidden) Flag
This flag causes the server to return a 403 Forbidden status code to the client. For Example
RewriteRule \.exe - [F]If anyone trying to open any file with .exe, he will get Forbidden error.
8. htaccess G(gone) Flag
This flag causes the server to return a 410 Gone status with the response code to the client. For Example
RewriteRule old_url - [G]If old_url called, 410 gone status will be shown in the browser.
9. htaccess H(handler) Flag
This flag causes Forces the request to be handled with the specified handler. For example
RewriteRule !\. - [H=application/x-httpd-php]Force all files without a file extension to be parsed by the php handler.
10. htaccess L(Last) Flag
This flag causes to stop processing the rule set, if the rule matches, no further rules will be processed.
RewriteRule ^(.*) /index.php?req=$1 [L]
11. htaccess N(Next) Flag
This flag causes ruleset to start over again from the top.
RewriteRule ^(.*) /index.php?req=$1 [N]
12. htaccess NC(nocase) Flag
This flag causes RewriteRule to be matched in a case-insensitive manner.
RewriteRule ^(.*) /index.php?req=$1 [NC]
13. htaccess NE(noescape) Flag
By default, special characters, such as & and ?, are converted to their hexcode equivalent. By Using NE flag prevents we can prevent this.
14. htaccess NS(nosubreq) Flag
This flag causes prevents the rule from being used on subrequests.
15. htaccess P(proxy) Flag
This flag causes the request to be handled by proxy request. For example, if you wanted all image requests to be handled by a image server
RewriteRule /(.*)\.(jpg|gif|png)$ http://images.mysite.com/$1.$2 [P]Extension having jpg, gif, and png will be handled by images.mysite.com
16. htaccess PT(passthrough) Flag
This flag causes the result of the RewriteRule to be passed back through URL mapping.
17. htaccess QSA(qsappend) Flag
When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.
18. htaccess S(Skip) flag
htaccess S flag is used to skip rules that you don't want to run. The syntax of the skip flag is [S=N], where N means the number of rules to skip. For Example
# Does the file exist? RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza. RewriteRule .? - [S=3] # IF the file exists, then: RewriteRule (.*\.gif) images.php?$1 RewriteRule (.*\.html) docs.php?$1 # Skip past the "else" stanza. RewriteRule .? - [S=1] # ELSE... RewriteRule (.*) 404.php?file=$1 # END
19. htaccess T(type) flag
htaccess T flag cause sets the MIME type with which the resulting response will be sent. For Example
RewriteRule IMG - [T=image/jpg]
20. htaccess R(Redirect) flag
htacces R flag causes a HTTP redirect to be issued to the browser. Normally Redirect does not occur but if we use R Flag, then redirection will be happened to the browser. For Example
RewriteRule (.*\.gif) images.php?$1 [R]
Best Related Posts are Following:
- How to redirect http to https in Zend Framework.
- Redirect internal links to another file with .htaccess.
- htaccess allow for IP address and should not ask for Authentication.
- How can I make a redirect page using javascript jQuery PHP and htaccess.
- Htaccess interview Questions and Answers for fresher and experienced.
- How to redirect https to http in htaccess.
- non-www Redirect to www htaccess.
- Wordpress redirect https to http with htaccess [SOLVED].
- Htaccess RewriteRule Flags by Code Example.
- htaccess code snippets example.
Friday 7 November 2014
Enabling the openssl in Wamp-Xampp
If you have any of following issue, then you are on right page.
- How to enable SSL
- Enabling the openssl in WampServer/xampp
- How to enable openssl support in XAMPP
- Unable to Connect to ssl
- Fatal error: Uncaught exception Zend_Http_Client_Adapter_Exception
Solution: enable the extension php_openssl from PHP Extension
Option 1 (If using Wamp-Server)
and Restart your wamp Server
Option 2 (Direct change in php.ini File)
You can do direct change
Just comment your php_openssl.dll in your php.ini file.
Search
;extension=php_openssl.dllReplace with
extension=php_openssl.dllHere we have just removed the semicolon.
Best Related Posts are Following:
- 301 or 302 Redirection With PHP and benefits.
- How to detect Mobile Device in PHP? - Simplest way.
- How to Create Thumbnail Images of uploaded image using PHP.
- Advanced PHP Interview Questions and Answers.
- Git interview questions and answers - Problem and Solutions.
- How to import csv file to database through phpmyadmin.
- How to export mysql query results to csv?.
- MySql replace NULL values with empty string without effecting Rowset.
- How to fix Headers already sent error in PHP?.
- Twitter login failed leads to Page not found.
- How to send an email using Email Template in Zend Framework.
- How do I get wordpress global variable and functions in custom file [SOLVED].
- How to convert php array into javascript array.
- How to store array in Cookie and retrieve array from cookie.
- Synchronous XMLHttpRequest on the main thread is deprecated.
- Send Email from Gmail SMTP using Zend Framework.
- HTML formatted email not showing up correctly in mail clients (Gmail-Outlook-Hotmail-Iphone-Android) [SOLVED].
- How to change the author of a post in Wordpress.
- How to clear Facebook image cache.
- Google trends api php - How to get hot trends.
- How can delete a user without deleting the post and comments in wordpress?.
- How to use MySQLi parameterized statements?.
- Wordpress redirect https to http with htaccess [SOLVED].
- PHP Technical Interview Questions and Answers for Fresher and Experienced.
- Wordpress Website title repeated two times in browser header [SOLVED].
- How can I prevent SQL-injection in PHP [SOLVED].
- Htaccess RewriteRule Flags by Code Example.
- Multiple column ordering in Zend Framework.
- Strtolower - Returns string with all alphabetic characters converted to lowercase.
- Enabling the openssl in Wamp-Xampp.
- How do I get a YouTube video thumbnail from the YouTube.
- How to find day of week in php in a specific timezone.
- Download Videos from Amazon S3 - PHP.
- Paypal Sandbox do-Directpayment, Authorization, Capture and Mass-payment - Example with Code Snippets.
- Image not displaying uploaded by CKeditor.
- Parse XML in PHP By example [Solved].
- jQuery multi column sorting with jQuery - Live Demo.
- How to Select / Deselect All Checkboxes using jQuery.
Tuesday 23 September 2014
Zend Cache Tutorial - Zend Framework 1.12
Zend_Cache provides a flexible approach toward caching data, including support for tagging, manipulating, iterating, and removing data.
Question: What is Zend Cache?
It is Inbuilt component of zend framework which is used to speed up the application by using the caching concept.
Question: Why we use Zend Cache?
We use Zend cache for different purpose are following
- Increase the website Performance.
- Reduce the load on database.
- Reduce the load of api, if using in application.
- To get the result faster.
What is the use of Zend Cache?
We can speedup our application as well as can reduce the burdon on database and API.
Zend_Cache use the file system to store the cache. We have option in zend cache to use the other caching component like Memcached, Sqlite, ibmemcached,Apc,Xcache and ZendPlatform etc. In this tutorial we will understand the zend_cache with file system.
How to Setup Zend Cache?
Step1: Add Following function Bootstrap
public function _initCache() { $cache = Zend_Cache::factory( 'Core', 'File', array( 'lifetime' => 3600 * 24 * 7, /*caching time is 7 days*/ 'automatic_serialization' => true ), array('cache_dir' => APPLICATION_PATH . '/cache' /* This is caching folder where caching data will be stored and it must be writable by apache **/ ) ); Zend_Registry::set('Cache', $cache); /* set the cache object in zend_registery so that you can globally access*/ }Step2: cache folder must be writeable by PHP
Step3: Now, Just use the zend cache
/* get the cache object */ $cache = Zend_Registry::get('Cache'); /* create a unique cache key */ $cacheKey = "mydata"; $result = array(); if (empty($cacheKey) || ($result = $cache->load($cacheKey)) == false) { /* Here Process the and store the data in $result variable */ $cache->save($result, $cacheKey); }
What is Tagging in Zend Cache?
Tags are a way to categorize cache records. You can add two OR more type of records in single tag. You can create unlimited tags and also can add unlimited records in single tag.
How to used Tagging in Zend Cache.
/* get the cache object */ $cache = Zend_Registry::get('Cache'); /* create a unique cache key */ $cacheKey = "mydata"; $result = array(); if (empty($cacheKey) || ($result = $cache->load($cacheKey)) == false) { /* Here Process the and store the data in $result variable */ $cache->save($result, $cacheKey , array('Tags')); }
Can we add multiple Tags for 1 Record?
Yes, We can do.
$cache->save($result, $cacheKey , array('Tag1','Tag2','Tag3'));
How can we clean one cache?
$cache->remove('idToRemove');
How to clean all records?
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
How to clean outdated records?
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);
How to clean all records of one/more tags?
$cache->clean( Zend_Cache::CLEANING_MODE_MATCHING_TAG, array('Tag1', 'Tag2') );
Best Related Posts are Following:
- How to send an email using Email Template in Zend Framework
- Get Youtube video-details and comments using PHP
- How to send Attachment in Email in zend framework1 - Send PDF File
- How to send Email in Zend Framework - HTML Email
- Send Email from Gmail SMTP using Zend Framework
- Google trends api php - How to get hot trends
- Multiple column ordering in Zend Framework
- Current time zone for a city- Free API
- Zend Gdata Youtube API - Search Video - View Video Detail
- Download Videos from Amazon S3 - PHP
- How to set Cron in Zend Framework
- Zend Cache Tutorial - Zend Framework 1.12
- Zend Framework Interview Questions and Answers for Experienced
- Zend Framework Interview Questions and Answers
- Zend Framework - Free Google Analytics API
- Zend_Filter_Input - Zend_Filter - Zend Framework
- PHP Upload File In Amazon S3 Bucket - Code Snippets
- Difference Between Zend framework 2 VS Zend framework 1
- Zend Database Query - Zend Profiler Example - Code Snippets
Thursday 24 July 2014
Important PHP Interview Questions and Answers - jQuery, SQL Modes, Client Programs and Reset
How to get jQuery nth Element
jQuery Multiple File Upload Plugin
http://www.fyneworks.com/jquery/multiple-file-upload/#tab-Overview
jQuery Paging
Here you can table Sorting, Searching and Paging in Easy Way
http://www.datatables.net/examples/
Paypal return error : malformed
Hi,
I am using payapl gateway for payment in my project.
It is working fine for sandbox(test account) but no working for paypal (original paypal detail on client server);
It return following errror from paypal
Array
(
[Error] => Array
(
[Number] => malformed
)
)
Solution: When you are sending amount in api call, sent amount with 2 digit decimal places. For Example 100.02 OR 22.32
How to Download Openinviter?
You want to implement openInviter and your project is in Wordpress, Joomla, Drupal, Social engine, phpBB, Dolphin, Symfony & webmail. then Its maximum 2-5 min work. Just download the plugin/component & install in your application it will start working.
What is PHP?
PHP is language that enable web-developer to create the dynamic web pages with the use of HTML/CSS/JavaScript.
What is Full Form of PHP?
Full Form of PHP is Personal Home Page but now it stand for PHP: Hypertext Preprocessor
Who is Father of PHP?
Rasmus Lerdorf
When php was invented?
PHP was created by Rasmus Lerdorf in 1995
What is Rest
REpresentational Sate Transfer.
It is set of architectural rules by which you design a web service that focus on transfer of data from one server to another ignorance of operating system and language.
It was introduced in 2000.
What is Invoking Client Programs?
MySQL client programs can be invoked from the command line. For example from a Windows console prompt OR a Unix shell prompt.
For Example
What are Server SQL modes?
It define what SQL syntax, MySQL should support and what kind of data validation checks it should perform.
It easier to use MySQL in different environments.
How many server SQL modes?
The MySQL server can operate in different SQL modes, and can apply these modes differently for different clients.
Thanks for reading our page
http://www.web-technology-experts-notes.in/2014/07/important-php-interview-questions-and-Answers.html
//include jQuery file <script type="text/javascript" src="jquery.js"></script> <script> function go_to(id_number){ var obj=jQuery('div.mydiv ul li:nth-child('+id_number+') a'); alert(obj.html()) } go_to(3); </script>
jQuery Multiple File Upload Plugin
http://www.fyneworks.com/jquery/multiple-file-upload/#tab-Overview
jQuery Paging
Here you can table Sorting, Searching and Paging in Easy Way
http://www.datatables.net/examples/
Paypal return error : malformed
Hi,
I am using payapl gateway for payment in my project.
It is working fine for sandbox(test account) but no working for paypal (original paypal detail on client server);
It return following errror from paypal
Array
(
[Error] => Array
(
[Number] => malformed
)
)
Solution: When you are sending amount in api call, sent amount with 2 digit decimal places. For Example 100.02 OR 22.32
How to Download Openinviter?
You want to implement openInviter and your project is in Wordpress, Joomla, Drupal, Social engine, phpBB, Dolphin, Symfony & webmail. then Its maximum 2-5 min work. Just download the plugin/component & install in your application it will start working.
If your project is in some other CMS or Core PHP, then you need to download the files.
Include the file & call the appropriate function. It will start working...
http://openinviter.com/download.php
http://openinviter.com/download.php
What is PHP?
PHP is language that enable web-developer to create the dynamic web pages with the use of HTML/CSS/JavaScript.
What is Full Form of PHP?
Full Form of PHP is Personal Home Page but now it stand for PHP: Hypertext Preprocessor
Who is Father of PHP?
Rasmus Lerdorf
When php was invented?
PHP was created by Rasmus Lerdorf in 1995
What is Rest
REpresentational Sate Transfer.
It is set of architectural rules by which you design a web service that focus on transfer of data from one server to another ignorance of operating system and language.
It was introduced in 2000.
What is Invoking Client Programs?
MySQL client programs can be invoked from the command line. For example from a Windows console prompt OR a Unix shell prompt.
For Example
shell> mysql -h localhost -p -u myname
What are Server SQL modes?
It define what SQL syntax, MySQL should support and what kind of data validation checks it should perform.
It easier to use MySQL in different environments.
How many server SQL modes?
The MySQL server can operate in different SQL modes, and can apply these modes differently for different clients.
Thanks for reading our page
http://www.web-technology-experts-notes.in/2014/07/important-php-interview-questions-and-Answers.html
Best Related Posts are Following:
- Advanced PHP Interview Questions and Answers.
- OOP Interview Questions and Answers.
- Top 10 PHP Interview Questions and Answers.
- PHP Questions and Answers for experienced.
- PHP Difficult Interview Questions and Answers.
- How to Detect Request type (GET OR Post ) in PHP.
- PHP Basic questions and answers for fresher and experienced.
- PHP Mysql Interview Questions and Answers for fresher and experienced.
- PHP interview questions and answers for 5 year experienced.
- PHP Frequently asked Questions and Answer 2015.
- PHP problem solving interview questions and answers for Fresher and Experienced.
- PHP Interview Questions and Answers for 2 year Experience.
- What is stdClass? and How to create stdClass class?.
- SPDY Protocol - Improve the Speed of web page.
- PHP Technical Interview Questions and Answers for Fresher and Experienced.
- How to stop parsing the HTML tags?.
- Difference between Notice and warning and fatal error.
- Object Oriented Programming in PHP.
- Htaccess RewriteRule Flags by Code Example.
- Enabling the openssl in Wamp-Xampp.
- Zend Cache Tutorial - Zend Framework 1.12.
- Important PHP Interview Questions and Answers - jQuery, SQL Modes, Client Programs and Reset.
- PHP DataStructures.
- PHP Check Mime Type of File - Return Information About A File.
- Zend Database Query - Zend Profiler Example - Code Snippets.
- Export to CSV File - PHP.
- htaccess code snippets example.
- CURL Example.
Thursday 5 June 2014
PHP DataStructures
Data structure is a way of storing and organizing data in a computer so that it can be used efficiently. It provide a efficient way to manage large amounts of data efficiently, such as large databases and Internet indexing services.
SPL provides a following set of standard datastructures.
SplDoublyLinkedList: The SplDoublyLinkedList class provides the main functionalities of a doubly linked list.
SplStack
The SplStack class provides the main functionalities of a stack implemented using a doubly linked list.
SplQueue
The SplQueue class provides the main functionalities of a queue implemented using a doubly linked list.
See Example
SplMaxHeap The SplMaxHeap class provides the main functionalities of a heap, keeping the maximum on the top.
SplMinHeap The SplMinHeap class provides the main functionalities of a heap, keeping the minimum on the top.
SplPriorityQueue The SplPriorityQueue class provides the main functionalists of an functionalists of an prioritized queue, implemented using a max heap.
SplFixedArray The SplFixedArray class provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is that it allows a faster array implementation. See Example Below
SplObjectStorage The SplObjectStorage class provides a map from objects to data or, by ignoring data, an object set. This dual purpose can be useful in many cases involving the need to uniquely identify objects.
SPL provides a following set of standard datastructures.
SplDoublyLinkedList: The SplDoublyLinkedList class provides the main functionalities of a doubly linked list.
SplStack
The SplStack class provides the main functionalities of a stack implemented using a doubly linked list.
SplQueue
The SplQueue class provides the main functionalities of a queue implemented using a doubly linked list.
See Example
echo "Create Object of SplQueue:"; $obj = new SplQueue(); echo " Check for Queue, is it Empty:"; if($obj->isEmpty()) { $obj->enqueue("Simple"); $obj->enqueue("Example"); $obj->enqueue("Of"); $obj->enqueue("PHP"); } echo "SplHeap The SplHeap class provides the main functionalities of a Heap. Heaps are crucial in several efficient graph algorithms such as Dijkstra's algorithm, and in the sorting algorithm heapsort.View queue:"; print_r($obj); if(! $obj->offsetExists(4)) { $obj->enqueue(10); } print_r($obj); echo ""; echo " Get the value of the offset at 3 "; if($obj->offsetGet(3)) { echo $obj->offsetGet(3); echo " Resetting the value of a node:"; $obj->offsetSet(4,6); }
SplMaxHeap The SplMaxHeap class provides the main functionalities of a heap, keeping the maximum on the top.
SplMinHeap The SplMinHeap class provides the main functionalities of a heap, keeping the minimum on the top.
SplPriorityQueue The SplPriorityQueue class provides the main functionalists of an functionalists of an prioritized queue, implemented using a max heap.
SplFixedArray The SplFixedArray class provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is that it allows a faster array implementation. See Example Below
$array = new SplFixedArray(5); $array[1] = 2; $array[4] = "foo"; var_dump($array[0]); // NULL var_dump($array[1]); // int(2) var_dump($array["5"]); // Fatal error: Uncaught exception 'RuntimeException' with message 'Index invalid or out of range'
SplObjectStorage The SplObjectStorage class provides a map from objects to data or, by ignoring data, an object set. This dual purpose can be useful in many cases involving the need to uniquely identify objects.
Best Related Posts are Following:
- PHP 7 new features.
- What is session_set_cookie_params.
- imagecreatefrompng - Create a new image from file or URL - PHP.
- count_chars - Count Number of character of string with PHP.
- Check if string contains specific words - PHP.
- New features of PHP 5.5 with Examples.
- New features of PHP 5.4 with Examples.
- How To Track the Real IP Address Behind the Proxy - PHP - REMOTE_ADDR.
- date_sunrise - Returns time of sunrise for a given day and location.
- Convert image to Binary Data and vice versa in PHP.
- Difference between in_array and array_key_exists in php with Example.
- get_class_vars PHP Function.
- get_class_methods PHP Function.
- mysql_fetch_field - Get column information from a result.
- PHP mktime() Function - Get Unix timestamp for a date.
- Strtolower - Returns string with all alphabetic characters converted to lowercase.
- PHP file_get_contents Function - Reads entire file into a string.
- PHP utf8_encode Function - Encodes an ISO-8859-1 string to UTF-8.
- com_create_guid Generate a globally unique identifier.
- spl_autoload What is spl_autoload function in php.
- parse_ini_string - Parse a configuration string.
- stream_socket_client - Open Internet or Unix domain socket connection.
- imagecopyresampled-Copy and resize part of an image with resampling.
- What is proc_close.
- What is str_getcsv.
- Perform a regular expression search and replace.
- fputcsv - Write in CSV File with PHP.
- realpath - Get the Real path of File with PHP.
- ob_get_level -Return the nesting level of the output buffering mechanism.
- openssl decrypt - Decrypts data.
- Domain Name Server.
- iterator_apply - Call a function for every element in an iterator - PHP.
- openssl private encrypt.
- openssl_pkcs12_read.
- mb_check_encoding.
- imagegrabwindow.
- imagealphablending.
- Gets options from the command line argument list.
- spl autoload extensions in PHP.
- Parse a binary IPTC block into single tags.
- Embeds binary IPTC data into a JPEG image.
- session_set_save_handler.
- mcrypt_encrypt.
- imagegrabscreen.
- imagecreatefromjpeg.
- stat Gives information about a file - PHP.
- fsockopen Open Internet or Unix domain socket connection- PHP.
- intval - Get Integer value from string in PHP.
- register_shutdown_function.
- setcookie - Store Cookie in Browser with PHP.
- header_remove - Remove the Header.
- proc_open.
- ucwords - Uppercase the first character of each word in a string.
- getimagesize -Get the size of an image - PHP.
- phpinfo - Outputs information about PHP's configuration.
- spl_autoload_register.
- json_encode - Returns the JSON representation of a value.
- mcrypt_decrypt.
- PHP Magic Methods with Examples.
Monday 19 May 2014
PHP Check Mime Type of File - Return Information About A File
Now a days, we are uploading files like Profile images, Video files OR excel files in our web application.
With uploading these files there are chances some user upload the .exe file (Virus) by renaming the .exe into .jpg, which can damage website.
You might have added the extension check from javaScript as well as PHP. But this is not enough from security end because someone can upload the file after changing the extension of file( ".exe" to ".png"). In this case your security check will be failed.
What to do.
Answer is check the Mime of file before get uploaded in your web server.
How to do this
"fileinfo" is extension which must be enabled in your php.ini. (for existence you can check in phpinfo)
If this extension is not enabled ask your server admin, he will do this for you OR you can also do this your self (http://php.net/manual/en/fileinfo.installation.php).
After installing the fileinfo extension, use following code to get the mime type of file before get uploaded in web server.
if (function_exists("finfo_file")) { $finfo = finfo_open(FILEINFO_MIME_TYPE); //file which you want to check the mime of the file $file = $_SERVER['DOCUMENT_ROOT'] . '/images/feedback.png'; //file which is going to get uploaded in web server try { $type = finfo_file($finfo,$file); echo "File Type: ".$type; } catch (Exception $e) { echo $e->getMessage(); } } else { echo "'finfo_file' is Not installed"; }
When you execute above code, if will get the mime-type of file. This is directly checking the mime type of already uploaded file.
You can use $type = finfo_file($finfo,$file); for checking the file type, before using move_uploaded_file function.
Best Related Posts are Following:
- Top 10 PHP Interview Questions and Answers.
- PHP Questions and Answers for experienced.
- PHP Difficult Interview Questions and Answers.
- How to Detect Request type (GET OR Post ) in PHP.
- PHP Basic questions and answers for fresher and experienced.
- PHP Mysql Interview Questions and Answers for fresher and experienced.
- PHP interview questions and answers for 5 year experienced.
- PHP Frequently asked Questions and Answer 2015.
- PHP problem solving interview questions and answers for Fresher and Experienced.
- PHP Interview Questions and Answers for 2 year Experience.
- What is stdClass? and How to create stdClass class?.
- Advanced PHP Interview Questions and Answers.
- SPDY Protocol - Improve the Speed of web page.
- PHP Technical Interview Questions and Answers for Fresher and Experienced.
- How to stop parsing the HTML tags?.
- Difference between Notice and warning and fatal error.
- Object Oriented Programming in PHP.
- Htaccess RewriteRule Flags by Code Example.
- Enabling the openssl in Wamp-Xampp.
- How to find day of week in php in a specific timezone.
- Zend Cache Tutorial - Zend Framework 1.12.
- Important PHP Interview Questions and Answers - jQuery, SQL Modes, Client Programs and Reset.
- PHP Check Mime Type of File - Return Information About A File.
- PHP Captcha Code Example Code Snippets.
- PHP - Secure Ajax Call from Hackers - Example.
- Zend Database Query - Zend Profiler Example - Code Snippets.
- Export to CSV File - PHP.
- htaccess code snippets example.
- OOP Interview Questions and Answers.
- CURL Example.
- PHP Interview Questions and Answers PDF.
- Stored Procedure - Advantage of Stored Procedure - Disadvantage of Stored Procedure.
- How To Track the Real IP Address Behind the Proxy - PHP - REMOTE_ADDR.
- Pending Interview Questions and Answers.
- Cache in PHP - Speed Up your website.
- PHP DataStructures.
- php interview questions and answers for 1 year experience.
- PHP Interview Questions and Answers for Experienced.
- Difference between Abstract class and Interface in PHP.
- Concurrent Connections of Apache Server.
- Regular Expressions PHP/Javascript.
- php interview questions and answers.
- What is Zend Engine in PHP.
Wednesday 5 March 2014
Zend Database Query - Zend Profiler Example - Code Snippets
Zend Profiler: It is used to display the queries executed by zend indirectly with MySql. It will show all the queries like insert, update, delete etc.
Zend Profiler is very important just because it show the queries but It can help you to improve the performance of your website.
See How you can use the Zend Profiler.
See below Example, How to use zend Profiler
5 Best Related Posts are Following:1. Web service - current time zone for a city- Free API
2. Zend Gdata Youtube API - Search Video - View Video Detail
3. Download the video from Amazon Simple Storage Service S3
4. How to set Cron in Zend Framework
5. Zend Cache Tutorial - Zend Framework 1.12
Zend Profiler is very important just because it show the queries but It can help you to improve the performance of your website.
See How you can use the Zend Profiler.
- With zend profiler you will get to know what type of queries are running in your application and which is making slow your website.
- Zend Profiler also also how much time each query is taking to execute.
- you can get to know, what are un-necessary queries are running
- What queries are running multiple times
- For future you can store these queries for further use.
See below Example, How to use zend Profiler
//create class class Application_Model_Test extends Zend_Db_Table_Abstract { protected $_name = 'tests'; protected $_primary = 'id'; //create function function insertData($data) { /** enable the zend profiler **/ $this->getAdapter()->getProfiler()->setEnabled(true); $profiler = $this->getAdapter()->getProfiler(); /** enable the zend profiler **/ //save data $this->insert($data); /** to list the mysql queries * */ foreach ($profiler->getQueryProfiles() as $query) { $sqlQuery = $query->getQuery(); $params = $query->getQueryParams(); echo $sqlQuery = str_replace(array('?'), $params, $sqlQuery); echo ''; } /** to list the mysql queries * */ } }
5 Best Related Posts are Following:1. Web service - current time zone for a city- Free API
2. Zend Gdata Youtube API - Search Video - View Video Detail
3. Download the video from Amazon Simple Storage Service S3
4. How to set Cron in Zend Framework
5. Zend Cache Tutorial - Zend Framework 1.12
Subscribe to:
Posts
(
Atom
)