Senin, 02 September 2013

Writing Style on PHP

In this thread i want to share about "Writing Style on PHP".

1. Echo
echo : used to print variable or character string without using format.
how to use:
echo "right";
echo ("right");

example:
$flname=Bagoes Rizaldy Setiambodo;
echo ("My Full Name is : %flname");


2. Print and Printf

Print : used to print variable or character string without using format.

example:
$flname=Bagoes Rizaldy Setiambodo;
print ("My Full Name is : %flname");

Printf : used to print variable or character string using format.

-> for String format use  : %s
-> for Integer format use : %d
-> for Decimal format use : %f

example:
$flname=Bagoes Rizaldy Setiambodo;
printf ("My Full Name is : %s",%flname);

echo does not have a return value while print has a return value that is
worth the amount of characters displayed.

3. Define constanta

for defining constanta, we just need tag:

define("name_constants",constants_values);

Arithmetic operators:
$a + $b = Addition (total of $a and $b)
$a - $b = Reduction (reduction of $a and $b)
$a * $b = Multiple (multiple of $a and $b)
$a / $b = Division (quotient of $a and $b)
$a % $b = Modulus (remainder of $a division $b)

Logic operators:
$a and $b = And (TRUE if $a and $b TRUE)
$a or $b  = Or (TRUE if $a or $b TRUE)
$a xor $b = Xor (TRUE if one of $a or $b TRUE)
  !$a     = Not (TRUE if $a not TRUE)
$a && $b  = And (TRUE if $a and $b TRUE)
$a || $b  = Or (TRUE if $a or $b TRUE)

Comparison operators:
$a == $b  = Equal (TRUE if $a = $b)
$a === $b = Identical (TRUE if $a = $b, and have same type)
$a != $b  = Not Equal (TRUE if $a not= $b)
$a <> $b  = Not Equal (TRUE if $a not= $b)
$a !== $b = Not identical (TRUE if $a not= $b, or have different type)
$a < $b   = Less than (TRUE if $a less than $b)
$a > $b   = Greater than (TRUE if $a greater than $b)
$a <= $b  = Less than or Equal to (TRUE if $a less than or same $b)
$a >= $b  = Greater than or Equal to (TRUE if $a greater than or same $b)

On the next Thread i'll share about the example project :)

0 comments:

Posting Komentar