
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1060 Articles for PHP

845 Views
Definition and UsageCallback is a pseudo-type in PHP. With PHP 5.4, Callable type hint has been introduced, which is similar to Callback. When some object is identified as callable, it means that it can be used as a function that can be called. A callable can be a built-in or user defined function or a method inside any class.The is_callable() function can be used to verify if the identifier is a callable or not. PHP has call_user_function() that accepts a function's name as a parameter.Following example shows a built-in function is a callable.Example Live DemoOutputThis will produce following result −bool(true)In following ... Read More

10K+ Views
Definition and UsageThis is one of the scalar data types in PHP. A boolean data can be either TRUE or FALSE. These are predefined constants in PHP. The variable becomes a boolean variable when either TRUE or FALSE is assigned.SyntaxResult of echoing TRUE value displays 1 while for FALSE it shows nothing. Using var_dump() function displays bool as type with valueBoolean constants are not case sensitive. That means TRUE is equivalent to true and FALSE is similar to FalseLogical operators return boolean valueCastingAny data type can be explicitly converted to boolean with the help of casting operator (bool) or (boolean), ... Read More

9K+ Views
Definition and UsageA PHP code script is a text file having .php extension and is stored on web server. The PHP parser on server looks for special sequence of characters . These are called PHP's opening and closing tags. Statements witihn these two are interpreted by the parser. PHP script within these tags can be embedded in HTML document, so that embedded code is executed on server, leaving rest of the document to be processed by client browser's HTML parser.SyntaxShort tagsPHP allows a using a shorter representation of opening tag PHP VersionThis setting is recommended to be Off for production ... Read More

1K+ Views
Definition and UsagePHP file can have mixed content with code within tags embedded in a HTML document. Code outside tags is ignored by the parser, leaving it to be interpreted by client browser. A HTML document can have multiple blocks of PHP, each inside tags.Syntax HTML block HTML block HTML block Every time opening PHP tag is encountered, parser starts rendering the output to the client until closing tag is reached. If code consusts of conditional statement, th parser determines which block to be skipped.Again till another opening tag comes, everything is treated ... Read More

7K+ Views
IntroductionPrecedence of operators decides the order of execution of operators in an expression. For example in 2+6/3, division of 6/3 is done first and then addition of 2+2 takesplace because division operator / has higher precedence over addition operator +. To force a certain operator to be called before other, parentheses should be used. In this example, (2+6)/3 performs addition first, followed by division.Some operators may have same level of precedence. In that case, the order of associativity (either left or right) decides the order of operations. Operators of same precedence level but are non-associativem cannot be used next to ... Read More

12K+ Views
IntroductionC style increment and decrement operators represented by ++ and -- respectively are defined in PHP also. As the name suggests, ++ the increment operator increments value of operand variable by 1. The Decrement operator -- decrements the value by 1. Both are unary operators as they need only one operand. These operators (++ or --) can be used in prefix or postfix manner, either as an expression or along with other operators in a more complex expression.Syntax$x=5; $x=5; $y=5; $x++; //postfix increment $y--; //postfix decrement ++$y; //prefix increment --$x; //prefix decrementWhen used independently, postfix and prefix increment/decrement operator ... Read More

2K+ Views
IntroductionThere is one Execution operator defined in PHP. A string inside back-ticks (``) is treated as a DOS command (a shell command in UNIX/Linux) and its output is returned. This operator is similar in operation to shell_exec() function in PHP.Following code executes DIR command and returns result as string.ExampleOutputFollowing result will be displayedVolume in drive C is Windows 10 Volume Serial Number is 540D-CE99 Directory of C:\xampp\php 01/27/2016 05:32 PM 18, 869 CompatInfo.php 07/08/2020 06:40 PM 64 test.php 07/11/2020 02:13 PM 48 testscript.php 03/30/2013 05:59 PM 1, 447 webdriver-test-example.php 4 File(s) 20, 428 bytes 0 Dir(s) 178, 002, 157, 568 ... Read More

2K+ Views
IntroductionIn PHP @ symbol is defined as Error Control Operator. When it is prefixed to any expression, any error encountered by PHP parser while executing it will be suppressed and the expression will be ignored.Following code tries to open a non-existing file for read operation, but PHP parser reports warningExample Live DemoOutputFollowing result will be displayedHello World PHP Warning: fopen(nosuchfile.txt): failed to open stream: No such file or directory in /home/cg/root/1569997/main.php on line 2Prepending @ symbol to fopen() expression suppresses error message and statement itself is ignoredExample Live DemoOutputFollowing result will be displayedHello World

11K+ Views
IntroductionAlmost everything in a PHP script is an expression. Anything that has a value is an expression. In a typical assignment statement ($x=100), a literal value, a function or operands processed by operators is an expression, anything that appears to the right of assignment operator (=)Syntax$x=100; //100 is an expression $a=$b+$c; //b+$c is an expression $c=add($a, $b); //add($a, $b) is an expresson $val=sqrt(100); //sqrt(100) is an expression $var=$x!=$y; //$x!=$y is an expressionexpression with ++ and -- operatorsThese operators are called increment and decrement operators respectively. They are unary operators, needing just one operand and can be used in prefix or ... Read More

5K+ Views
IntroductionThe goto statement is used to send flow of the program to a certain location in the code. The location is specified by a user defined label. Generally, goto statement comes in the script as a part of conditional expression such as if, else or case (in switch construct)Syntaxstatement1; statement2; if (expression) goto label1; statement3; label1: statement4;After statement2, if expression (as a part of if statement) is true, program flow is directed to label1. If it is not true, statement3 will get executed. Program continues in normal flow afterwards.In following example, If number input by user is even, program ... Read More