Category «Learn PHP programming, training and tutorials»

PHP

PHP useful links

Here I will update the most interesting and useful links which I found related to php. I encourage you to fill out this list posting your favorite php links in your comments. HTTP Status Code Checker Bulk url http status checker – check status codes, response headers, and redirect chains. Web-sniffer.net – View HTTP Request …

Smart Search for PHP

Creating Autocomplete or Search Suggestion Functionality with PHP What is Fuzzy matching Fuzzy matching treats two words that are “fuzzily” similar as if they were the same word. In 1965, Vladimir Levenshtein developed the Levenshtein distance, which measures the number of single-character edits required to transform one word into the other. He proposed three types …

PHP dates and times

time() time() function returns the current time in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) Epoch time = Unix timestamp The valid range of a timestamp correspond to the minimum and maximum values for a 32-bit signed integer, for example zero = January 1 1970 00:00:00 32bit = timestamp …

PHP array functions

List of functions that work with php arrays. array_shift() array_shift() – Shifts the first value of the array off and returns it, shortening the array by one element and moving everything down. All numerical array keys will be modified to start counting from zero while literal keys won’t be touched. array_pop() array_pop() – pop the …

PHP Display errors & Debug

To turn on error reporting 1. Set in php.ini 2. In php.code Check error logs on apache server Check errors in log file that is configured in etc/apache2/httpd.conf DEBUG Php useful debugging functions gettype($variable) – Get variable type; var_dump($variable) – Dumps information about a variable; get_defined_vars() – Return an array of all defined variables; debug_backtrace() …

Limiting upload file size in PHP

Limiting upload file size We can configure upload max file size in php.ini file, but this is a global maximum for all of PHP. If we want to configure max file size in a particular case, we can do that by adding an attribute to HTML form for MAX_FILE_SIZE. PHP will automatically detect that value …

PHP Arrays

An array is a collection of related values (a list of items) such as names of cities Creating an array $numbers = array(); //empty array To create an array use the function array() like: Numeric Arrays Numeric Arrays are arrays that use only numeric keys, called as numeric, indexed or ordered arrays. Associative Arrays Associative …

PHP Conditional Statements: if else, switch

If statement Execute the code if the condition is true If…else statement Switch statement Execute different code depending on a condition. The switch statement is similar to a series of IF statements If the value pass to the switch statement matches, the code that follows the case is executed. Example: Be careful! if we forget …

Difference between single-quoted and double-quoted

The most important difference between single and double quote, is that anything enclosed in single quotes is treated as literal text. Single quotes When using single quotes we must take care with apostrophes. To use the apostrophe in single quotes, we have to put backslash before apostrophe (which is named as escape character). The backslash …