MemoryRefresh!

Basics



Questions 1 Answers 0%

Pages   0 from 51
Questions   0 from 84

Reset



Single quotes - will be recorded as is
<?php $a = 'a'; echo $b = '$an'; // output $an // --- Look Here --- // Double quotes - will be interpreted and replaced
<?php $a = 'a'; echo $b = "$an"; // output a // --- Look Here --- // Braces - used when parser is not able to parse a variable
<?php $a[1] = 'Smith'; echo "John {$a[1]}[1974]"; // John Smith[1974] // --- Look Here --- // Herodoc - similar with double quotes, but for multiple lines It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon (;).
<?php // allows the use of quotes without escaping $who = "John"; $output = <<<TEST She said "This is $who's test" on multiple rows TEST; // --- Look Here --- // echo nl2br($output); /* output She said "This is John's test" on multiple rows */ Nowdoc - no parsing is done inside
<?php $who = "John"; $str = <<<'TEST' // --- Look Here --- // She said "This is $who's test" on multiple rows TEST; echo nl2br($str); /* Outputs: She said "This is $who's test" on multiple rows */ Length - strlen()
<?php //all characters in the string are counted, regardless of their value echo strlen("abc"); // 3 echo strlen(""); // 0 // --- Look Here --- // echo strlen(" "); // 1 echo strlen("n"); // 1 echo strlen('n'); // 1 echo strlen(NULL); // 0 echo strlen(0); // 1 echo strlen(TRUE); // 1 echo strlen(FALSE); // 0 // --- Look Here --- // Concatation - with comma is faster then dot
<?php echo "a" . "b"; // Output: ab echo "a" , "c"; // Output: ac // --- Look Here --- // Using Strings as Arrays
<?php $str = "abcdef"; echo $str[1]; // b // --- Look Here --- // String automatic conversion
<?php echo "a" . "b"; // Output: ab echo 1 . 2; // Output: 12 echo "a" + "b"; // Output: 0 echo "a" + 1; // 0 + 1 // --- Look Here --- // // Output 1 echo "a" * 2; // 0 * 2 // Output 0 Operator Precedence and Associativity * / % Highest Precedence + - . < <= > >= = = = != = && || And XOR OR Lowest Precedence
<?php // * / % echo 10 / 2 * 5 % 7; // 5 * 5 % 7 = 25 % 7 = 4 // Output: 4 // + - . echo "aa" . 1 + 2 . 'b'; // Output: 2b // --- Look Here --- // // "aa1" + 2 . 'b' // 0 + 2 . 'b' = 2b // * / % precedence over + - . // --- Look Here --- // echo "aa" . 1 * 2 . '0'; // Output: aa20 // + - . precedence over > < echo 3 - 2 < 2 ; // Output 1 echo 3 - (2 < 2) ; // Output 3
Questions

Related pages

Basics !
Comparing !
Searching !
Parse !
Replacing !
Formatting !
Printf !
Regexp !
Datetime !


0% 100%
 
 
0 pages 51 pages
1) What is the output of the following code? <?php $a = "a"; echo "$a" . '$an';





2) Where are the braces used correctly?




3) Which rule for herodoc strings is correct?





4) When is the returned value equal to 1?






Last Review: n/a   Passed: n/a   Reviews: n/a   Next Review: n/a  


Single quotes - will be recorded as is
<?php $a = 'a'; echo $b = '$an'; // output $an // --- Look Here --- // Double quotes - will be interpreted and replaced
<?php $a = 'a'; echo $b = "$an"; // output a // --- Look Here --- // Braces - used when parser is not able to parse a variable
<?php $a[1] = 'Smith'; echo "John {$a[1]}[1974]"; // John Smith[1974] // --- Look Here --- // Herodoc - similar with double quotes, but for multiple lines It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon (;).
<?php // allows the use of quotes without escaping $who = "John"; $output = <<<TEST She said "This is $who's test" on multiple rows TEST; // --- Look Here --- // echo nl2br($output); /* output She said "This is John's test" on multiple rows */ Nowdoc - no parsing is done inside
<?php $who = "John"; $str = <<<'TEST' // --- Look Here --- // She said "This is $who's test" on multiple rows TEST; echo nl2br($str); /* Outputs: She said "This is $who's test" on multiple rows */ Length - strlen()
<?php //all characters in the string are counted, regardless of their value echo strlen("abc"); // 3 echo strlen(""); // 0 // --- Look Here --- // echo strlen(" "); // 1 echo strlen("n"); // 1 echo strlen('n'); // 1 echo strlen(NULL); // 0 echo strlen(0); // 1 echo strlen(TRUE); // 1 echo strlen(FALSE); // 0 // --- Look Here --- // Concatation - with comma is faster then dot
<?php echo "a" . "b"; // Output: ab echo "a" , "c"; // Output: ac // --- Look Here --- // Using Strings as Arrays
<?php $str = "abcdef"; echo $str[1]; // b // --- Look Here --- // String automatic conversion
<?php echo "a" . "b"; // Output: ab echo 1 . 2; // Output: 12 echo "a" + "b"; // Output: 0 echo "a" + 1; // 0 + 1 // --- Look Here --- // // Output 1 echo "a" * 2; // 0 * 2 // Output 0 Operator Precedence and Associativity * / % Highest Precedence + - . < <= > >= = = = != = && || And XOR OR Lowest Precedence
<?php // * / % echo 10 / 2 * 5 % 7; // 5 * 5 % 7 = 25 % 7 = 4 // Output: 4 // + - . echo "aa" . 1 + 2 . 'b'; // Output: 2b // --- Look Here --- // // "aa1" + 2 . 'b' // 0 + 2 . 'b' = 2b // * / % precedence over + - . // --- Look Here --- // echo "aa" . 1 * 2 . '0'; // Output: aa20 // + - . precedence over > < echo 3 - 2 < 2 ; // Output 1 echo 3 - (2 < 2) ; // Output 3



More from Php

Basics
Variables
Operators
Function
Array
String
Streams
Uncategorized


More from Programming

Php
jQuery




Powered by minte9.com