PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. It is an interpreted language, i.e. there is no need for compilation.
<?php// Concatenationecho'Hello, my name is '.$name.' and I am '.$age.'.';echo"Hello, my name is $name and I am $age.";$name='Zeniter';// String functionsechostrlen($name).'<br>';// 7echostrtoupper($name).'<br>';// ZENITERechostrtolower($name).'<br>';// zeniterechostr_replace('e','f',$name).'<br>';// Zfnitfrechostr_replace('t','',$name).'<br>';// Zenierechosubstr($name,1,3).'<br>';// eniechostrrev($name).'<br>';// retineZ?>
<?php// Create an array$peopleOne=array('Benoîte','Monique','Sara');$peopleTwo=['Benoîte','Monique','Sara','Karen'];$ages=[20,30,40,50];// Print the whole arrayprint_r($peopleOne);// Array ( [0] => Benoîte [1] => Monique [2] => Sara )// Get element by indexecho$peopleOne[1];// Monique// Set element by index$peopleOne[1]='Alice';echo$peopleOne[1];// Alice// Add element$peopleOne[]='Mary';// Print the whole arrayprint_r($peopleOne);// Array ( [0] => Benoîte [1] => Alice [2] => Sara [3] => Mary )// Add element at the beginning of the arrayarray_unshift($peopleOne,'Bob');// Remove element from the end of the arrayarray_pop($peopleOne);// Remove element from the beginning of the arrayarray_shift($peopleOne);// Split the string into an array$string='Banana,Apple,Peach';echo$string;// Banana,Apple,Peachecho'<br>';$fruits=explode(',',$string);print_r($fruits);// Array ( [0] => Banana [1] => Apple [2] => Peach )?>
PHP booleans can be true or false. They are case insensitive. TRUE, True and true are all valid. 1 is also considered as true and 0 as false. null is considered as false.