PHP Symbols – What Does This Symbol Mean in PHP?
PHP . (dot/decimal point)
What does a . (dot) do in PHP? (Source: Stack Overflow)
“.” and “.=” String Operators (Source: PHP.net manual)
There are two string operators. The first is the concatenation operator (‘.’), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator (
'.=‘), which appends the argument on the right side to the argument on the left side.
$a = "Hello "; $b = $a . "World!"; // now $b contains "Hello World!" $a = "Hello "; $a .= "World!"; // now $a contains "Hello World!"
Learning PHP: Concatenate Strings and Variables Efficiently (Source: WP Shout)
Building Strings with Dots and Variables – Video from Know the Code
PHP “Double-quote” vs ‘Single-quote’
What is the difference between single-quoted and double-quoted strings in PHP? (Source: Stack Overflow)
Things get evaluated in double quotes but not in single:
$s = "dollars"; echo 'This costs a lot of $s.'; // This costs a lot of $s. echo "This costs a lot of $s."; // This costs a lot of dollars.
What is the difference between single-quoted and double-quoted strings in PHP? (Source: GeeksforGeeks)
‘Single-quoted’ strings: It is the easiest way to define a string. You can use it when you want the string to be exactly as it is written. All the Escape sequences like \r or \n, will be output as specified instead of having any special meaning. See examples
“Double-quoted” strings: By using Double quotes the PHP code is forced to evaluate the whole string. The main difference between double quotes and single quotes is that by using double quotes, you can include variables directly within the string. It interprets the Escape sequences. Each variable will be replaced by its value. See examples
PHP -> (Object Operator) and => (Double Arrow Operator)
What Does This Mean in PHP -> or => (Source: Stack Overflow)
The object operator,
->, is used in object scope to access methods and properties of an object. Its meaning is to say that what is on the right of the operator is a member of the object instantiated into the variable on the left side of the operator. Instantiated is the key term here.
// Create a new instance of MyObject into $obj $obj = new MyObject(); // Set a property in the $obj object called thisProperty $obj->thisProperty = 'Fred'; // Call a method of the $obj object named getProperty $obj->getProperty();
The double arrow operator,
=>, is used as an access mechanism for arrays. This means that what is on the left side of it will have a corresponding value of what is on the right side of it in array context. This can be used to set values of any acceptable type into a corresponding index of an array. The index can be associative (string based) or numeric.
$myArray = array( 0 => 'Big', 1 => 'Small', 2 => 'Up', 3 => 'Down' );