Posts Tagged with 'PHP'

PHP | Output of the following statements var_dump(0123 == 123); var_dump('0123' == 123); var_dump('0123' === 123   var_dump(0123 == 123) This will output bool(false) because the leading 0 in 0123 tells the PHP interpreter to treat the …

Last updated 6 years, 2 months ago | 2669 views

Tags:- PHP

PHP | output of $a and $b once this code $a = '1'; $b = &$a; $b = "2$b" executed; Both $a and $b will output a string "21".   Because the statement $b = &$a; sets …

Last updated 6 years, 2 months ago | 2232 views

Tags:- PHP

PHP | Get URL with Parameter To get the full URL of a current page with GET parameters, we use the $_SERVER global variable. We need the current URL to perform different types of works. For …

Last updated 6 years, 5 months ago | 7418 views

Tags:- PHP

SQL | IN operator with PHP Array In this article we will use PHP Array with SQL IN operator. SQL IN operator allows us to specify multiple values in where clause. So in this article …

Last updated 6 years, 6 months ago | 2893 views

Tags:- PHP PHP-MySQL

PHP | file_exists( ) Function The file's existence can be confirmed using the file_exist() function which takes the file name as an argument. file_exist("abc.jpg")   The file_exists() function is an inbuilt function in PHP that …

Last updated 6 years, 7 months ago | 3474 views

Tags:- PHP

PHP | check whether a number is even or odd A trick to check whether a number is even or odd without using any condition or loop.   <?php $arr=array("0"=>"Even","1"=>"Odd"); $check=13; echo "Your number is: ".$arr[$check%2]; …

Last updated 6 years, 7 months ago | 4134 views

Tags:- PHP

Session V/S Cookies A cookie is an array of data stored by the browser on the client location and sent to the server with every request. It stores a limited amount of data about 4kb(i.e.: 4096 …

Last updated 6 years, 7 months ago | 2189 views

Tags:- PHP

PHP | Nested ternary conditional operator An example code showing the nested ternary conditional operator in PHP. <?php $background_color = ($num == 0 ? 'blue' : ($num > 0 ? 'green' : 'red')); ?> Here …

Last updated 6 years, 7 months ago | 3900 views

Tags:- PHP

PHP | Convert Object To  Array Converting an object to an array is a small thing that can be achieved by a single line of code. For this purpose, we need to use typecasting. Typecasting …

Last updated 6 years, 7 months ago | 2780 views

Tags:- PHP

PHP | Converting array of objects to array Array of objects look like this: Array ( [0] => stdClass Object ( [id] => 1 [name] => Ram [roll] => 12 ) [1] => stdClass Object ( …

Last updated 6 years, 7 months ago | 2587 views

Tags:- PHP

PHP | Sort an array of arrays by date in PHP Here a situation in which we have to sort an array of the array by date. An array of arrays is a multidimensional array in …

Last updated 6 years, 7 months ago | 2535 views

Tags:- PHP

PHP | Length of a string There is a string function called strlen() which is used to find the length of a string. It accepts a string that returns the length of the given string.  …

Last updated 6 years, 8 months ago | 2380 views

Tags:- PHP

PHP | Combine two strings There are several ways to concatenate two strings in PHP. Use the concatenation operator [.] and [.=] There are two string operators that are used for concatenation. [.]:  Concatenation operator …

Last updated 6 years, 8 months ago | 5123 views

Tags:- PHP

PHP | Remove duplicate value from an array  Duplicate value can remove from an array by using the array_unique function. If two or more array values are the same, the first appearance will be kept …

Last updated 6 years, 8 months ago | 2406 views

Tags:- PHP

PHP | Access specifiers An access specifier is a code element that is used to determine which part of the program is allowed to access a particular variable or other information.   There are three …

Last updated 6 years, 8 months ago | 2524 views

Tags:- PHP