Bash

PHP


#!/bin/php
#
#!/bin/php
#

Comments

#This is a shell comment
# This is a php comment
// This is a php comment
/* This is a multiline comment */

Variables

hello="Hello"
hello = "Hello"   #ERROR, there is space after hello
export hello="Hello"
export world="$hello world";
export a= "Hello" #NO ERROR but a is empty
var $hello = "Hello";
$hello = "Hello";
$world = $hello . " world";

Operators

val=`expr 2 + 2`
echo "Sum: $val"
$val = 2 + 2;
echo "Sum:  $val";

Logical

if else

a=10
b=20
if [ $a == $b ]
then
    echo "a is equal to b"
else
    echo "a is not equal to b"
fi
#---------
a="20 a"
b="20"
if [ $a == $b ] #ERROR: use "$a"=="$b"
then
    echo "a is equal to b" 
fi
$a=10;
$b=20;
if ($a==$b){
    echo "a==b";
}
else{
    echo "a!=b";
}

for

for a in ${arr[@]}
do
 echo $a;
done
for ($i=1; $i<=5; $i++) \
{
    echo $i;  
}

String

Boolean

Numeric

Calculate

Echo & print

Function

Array

File

Net