htmlspecialchars only takes care of <, >, single quote ‘, double quote ” and ampersand. htmlentities translates all occurrences of character sequences that have different meaning in HTML.
Difference between echo, print and printf
echo is the most primitive of them, and just outputs the contents following the construct to the screen. print is also a construct (so parentheses are optional when calling it), but it returns TRUE on successful output and FALSE if it was unable to print out the string. However, you can pass multiple parameters to echo, like: Continue reading
Magic Methods
PHP reserves all function names starting with __ as magical.
__sleep :- This function is executed prior to any serialization. It can clean up the object and is supposed to return an array with the names of all variables of that object that should be serialized. If the method doesn’t return anything then NULL is serialized and E_NOTICE is issued.
__wakeup :- The intended use of __wakeup is to reestablish any database connections that may have been lost during serialization and perform other reinitialization tasks.
__toString :- The __toString method allows a class to decide how it will react when it is converted to a string.
__invoke :- The __invoke method is called when a script tries to call an object as a function.
__set_state :- This static method is called for classes exported by var_export() since PHP 5.1.0.
The only parameter of this method is an array containing exported properties in the form array(‘property’ => value, …). Continue reading
Difference between include and require
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
PHP Code :
<?php require 'vars.php'; include 'vars.php'; ?>
Changing fieldset tag line color
This can be done by using the style property of <fieldset> tag
Code Sample :
<fieldset style="border-color: #ff0000;">




