- PHP Code :- For Partiality and Compatibility always use the long form.
Sort form : <? Expn ?>
Sort form equivalent of <? echo ?>
Note : No closing semicolon (;) is required <? Expn ?>
- Semicolon (;) :- All statement must end in a semicolon (;) otherwise, errors will be generated. If the error doesn't make sense. You probably are missing a semicolon somewhere !
- Single Quotations ('') :- Single quotes content inside single quotes is evaluated literally.Therefore $ string actually means ( dollar sing ) string and does not represent the variables.
$string = ' single quoted ';
echo '$string';
- Double Quotes ("") :- Double Quoted variable inside double quotes are evaluated for their value.
$string=" double quoted ";
echo "$string";
- Backslash ( Escape character ):- Escapes character that sold be evaluated literally when inside inside double quotation.
$string= "double quoted";
echo "\$string is set as $string";
$string is set as double quotes.
- Special characters :-
Question mark (?)
Single Quotes (')
Double Quotes (")
Doller sing ($)
- Comments :- Single line for everything to the right of the double forward slashes.
Multiple line opening and closing tags.
/* This is a comment */
- Formatting Character :-
\r - Carriage return
\t - Tab
\b - Back space
- Define (name, value [$Boolean]):-
Example:
define('Hello', 'Hello word!' );
echo Hello;
Output: Hello word!
- Function:- Function function name(argument) {},
Example:
hello();
// Above the conditional statement this will cause an error
if(0==0)
{
function hello()
{
echo 'Hello';
}
}
Fatal error: call to undefined function hell()
if(0==0)
{
function hello()
{
echo 'Hello ';
}
}
hello();
there();
function there()
{
echo 'there';
}
Hello there: function can have a argument (as above), argument passed to them, an default arguments with passed argument as optional. The argument names are use within that function as variable name.
Example:
function args($a,$b)
{
// has no default values request to input
echo "a=$a, b=$b";
}
args(1,2);
Output:
a=1,b=2

No comments:
Post a Comment