PHP Syntax

Heya guys,

I'm trying hard to learn php at home. I got this book thing (Apress - PHP for Absolute Bigenners 2009). As I go through it and reached script writing, I realized that I still don't know the definitions/meanings of each terms, symbols and syntax that PHP uses for script writing like for example the ('), ("), ({}) and some other stuff used to construct a script. I hope I can read from you guys, the only experience I have in programming before is Turbo Pascal. I do apologize for this silly question. I can't find any PHP syntax dictionary online, do I need to practice another language before getting to PHP or something? I hope you guys understand what I'm trying to say, I don't know the right word to use.

Thank you for replying. God Bless.


  • I hope this helps, I am fairly new to php myself, but have figured out a lot of it. The curly brackets. i.e. {}, are used to delimit parts of your code. They mark starting and stopping points for actions in if then statements.
    if (foo){
    So in this sense it is used thusly if some condition is met, then some action must be followed, and that action is the code contained in the curly brackets, if that condition is not met then the action is the code in the curly brackets below the else statement.
    Another use of the curly brackets is to delimit functions.
    function foobar($foo, $bar)
    if($foo == $bar){
    $foobar = true;
    return $foobar;
    $foobar = false;
    return $foobar;}
    There you see a simple function that you can call to tell if two variables are equal or not. Obviously more indepth checks can be done, but this shows how the curly brackets are mainly used.
    As for the single and double quotes those are quite useful.
    Single quotes mark the beginning and end of a pure string. they can be used like this
    echo'hello world';
    No php parsing is done to strings contained in a set of single quotes, so you must concatenate with a period to include variables into the echo function like this.
    $world = 'world';
    echo'hello ' . $world;
    The result would be the same, as the previous echo statement.
    Lastly I get to the double quotes, double quotes denote a string with php variables in it. Therefore you can take the previous script and modify it like this
    $world = 'world';
    echo"hello $world";
    This works because the double quotes indicate that php needs to parse the string before it is used. However it should be noted that this is more system intensive than concatenation and is useful, but be careful.
    I hope this helps :)
  • Thanks very much 1337noob. This is the kind of site im lookin for. Thanks!
  • Thank you moofoo i appreciate your help. thanks much!
  • Hello all...
    If you are using a single statement in if or else condition then there is no need to put a curly braces({}).
    They make no sense for the single statement..
    It works similarly without curly braces.

    Thanks and Regards.


  • PHP code is executed on the server, and the plain HTML result is sent to the browser. A PHP scripting block can be placed anywhere in the document. It always starts with <?php and ends with ?>.
    The example of PHP code from [link=]php tutorials[/link] sends the text
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!