14 Major PHP Keynotes for Developers

14 Major PHP Keynotes for Developers

Have you been programming in a C-style programming language, and have just been recruited in a PHP project? Are you tired of studying the basic common programming structures again and again every time you learn a new language? Do you want a quick gist of what’s different in PHP and would like to get going right away? Here is what you should know.

Note: This is not an exhaustive list of the features specific to PHP. For complete details refer to official documentation and relevant books.

PHP Official Docs: http://php.net/docs.php

1.  “$” precedes every variable name.

$helloworldstr = “Hello World”

2. PHP is a dynamic-typed or weakly-typed language.  There is no need to define the data type of variable (string, int, char) , and the data type is figured out dynamically at runtime.

$intVal = 5;
$floatVal = 5.5
$strVAl = “HelloWorld”

3. Variable names are case sensitive, method/class names are case insensitive.

function ab(){                         
echo “11”;
Ab(); // Output: 11
AB(); // Output: 11
aB(); // Output: 11


class apple{
$obj = new aPPLE;
if($obj instanceof apple){
  echo "true";
} // Output: true


4. “.” (dot) is the  string concatenation operator

$a = “Hello”;
$b= ”World”
echo $a.$b; //Output HelloWorld


5. Array can be casted to an Object and vice-versa.

$object = (object) $array;
$array = (array) $object;


6. References implement referring count, when no variables reference a memory, the memory is automatically deallocated. Hence, it’s not necessary to free memory unless specifically needed.

7. PHP implements Copy-On-Write

$a = array(5,6,7);
$b = $a; // No separate memory assigned to b. a and b point to same memory location. 
$b[0] = 9 // Now a separate memory assigned to b and $a[0] is still 5.


8. Switch statement can have a String type value.

    case 'hello' :  echo "hello";
  case 'world' : echo "world";


9. PHP has more efficient For Loops : foreach

foreach ($array as $value) {
	// ...
foreach ($array as $key => $value) {
	// ...


Note: The foreach construct does not operate on the array itself, but rather on a copy of it. You can insert or delete elements in the body of a foreach loop, safe in the knowledge that the loop won’t attempt to process the deleted or inserted elements.

10. A function can be called before declaration as PHP parses the file then executes it.

11. Global variables in PHP are not available inside function bodies by default. To use global variables inside a function, use the “global” keyword.

$a = 3;
function foo()
global $a;
$a += 2;


12. Variable number of arguments can be passed to a function, use func_get_args() to find out the incoming arguments.

13. String within “” double quotes are interpolated and within single quote are not. Interpolation means replacement of variables by its values.

$num = 55;
$singleQuoteStr = 'apple{$num}';
$doubleQuoteStr = "apple{$num}";

echo $singleQuoteStr; // Output: apple{$num}
echo $doubleQuoteStr; // Output: apple55


14. Variables can be assigned function name strings. And can be used in this way to call functions

$which = "first";
if (function_exists($which)) {
$which(); // if $which is "first", the function first() is called, etc...


15. Check out PHP Magic Constants. They come in very handy while coding.


USA408 365 4638


1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Contact us

Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.

Tel: +1 408 365 4638
Support: +1 (408) 512 1812