Zend PHP Certification studies part 1: Basics

Each Friday, I will be posting some memory helpers and other notes recollected during my preparation for the Zend PHP 5.3 Certification.
The multiple choice test is composed by around 70 random Generated questions to be accomplished in 90 minutes.

For those of you that want to know a bit more in deep, it’s composed of the following 10 categories

FIRST PART: BASICS / WEIGHT IN THE CERTIFICATION – None is Lowest
• 1 PHP Basics / HIGH
• 2 Data Formats
 and Types
• 3 Strings / AVERAGE
• 4 Arrays / AVERAGE
• 5 Input Output

SECOND PART
• 6 Functions / AVERAGE
• 7 OOP / AVERAGE
• 8 Datatables
• 9 Security / HIGH
• 10 Web Features
 / HIGH

Your options vary. But if you are a lazy student like me, you will focus on the most important High and Average sections, because failing in those will be pricey.

This entry is dedicated to the first category, the Php basic syntax, variables and control structures. At the first sight the Certification looks very easy. But after making some tries, you get to realize that there are some tricky questions, that can be assumed easy but are an easy fail if you miss the point. So this entries will be just a reminder with some common failures and assumptions just to point where is wrong and how to avoid it.

SYNTAX FOCUS

// TAGS Opening and Closing Php Code
OPENING ... CLOSING ...
<?php        ?>
<script type="text/javascript" language="php"> </script>

//COMMENTS
/*
* Larger comments
*/

Operators
Basic + – * /
Modulus $m = 5%2 ; // 1 the leftover when 5 / 2

Bitwise Operators
LOGICAL SYMBOL CRITERIA (BY PLACE)
AND & MATCHING “1” IN BOTH OPERANDS
OR | AT LEAST ONE “1” IN AN OPERAND
EITHER-OR ^ ONLY ONE “1” IN BOTH OPERANDS

SHIFT BITS
<> 2 == 1 [LIKE DIVIDING BY 4]

NEGATE BITS
~ MOVE BITS BY X TIMES (CONVERT 0S INTO 1S; 1S INTO 0S)

Combined Forms with operators: + – * /
Ex: $a -=1; equals $a= $a-1;

Concatenating ( .= )
Ex: $a = “Good “;
$a .=”Morning Martin!”;

Increase / Decrease ( ++ or – – )
This is really important! Placement matters
PRE

$a= 2;
// PRE operations first perform the operation, then return value
echo  ++$a;   // Returns 3

POST

$a= 2;
// Post operations first return value, then perform the operation
echo  $a--;   // Returns 2

Comparison Operators
EQUALITY ( == ) INEQUALITY ( != )

=== Checks also that the data type is equal. This is very important!
Because sometimes “0” is not equal than false and so on. Checking for the type of data is sometimes a must.

This two little important things, Post and Pre combined with the data type check, lead to errors in the most important parts of the exam. Since like I commented before, many questions include little functions that play around this concepts.

Operator precedence
Follows mathematical precedence in most instances (EX:
Multiplication/Division precedes Addition/Substraction)
• Use of parentheses to enforce NON-STANDARD PRECEDENCE

VARIABLES
Naming conventions

 

  • Start with a $
  • Can have letters, numbers and underscores ( But no – signs   $a-test will give a syntax error )
  • They are case sensitive!

Referencing

Variables can be assigned by value or reference in a function declaration  ( &$a )

<?php
function foo(&$var) {
    $var++;
}

$a=3;
foo($a); // $a will return 4
?>

In the php manual there is an interesting Note if you want to make some reference exercises.

Create a website or blog at WordPress.com

%d bloggers like this: