Minggu, 01 November 2009

PHP Basics 3

For starters, please note that the PHP code will be placed in HTML pages. And the same with HTML, PHP codes made in the form of plain text. Thus, a page that displays the words "you're on a site Prothelon!" Will be in an HTML page which must be named file.php.

With these examples would have seen how it work? HTML still treated as HTML in general, but all that is between the tags Will be processed as PHP. Results output from the PHP process that will be displayed by the HTML to the browser. Note that if you save a file with the extension .htm / html, then the browser will also appear to display php tags but also do not process it, so that they appear like this:

print ( "You are in Prothelon site!");

?>


Whereas if you keep the extension. Php, so that appears only:
You are in Prothelon site!


Basic Syntax
Once you understand how a PHP and HTML code are combined and processed, it is time for you to write your first PHP script. Basic rules are briefly as follows:

File Naming
In order for PHP scripts to work, the file where we are php code must end with the extension. Php (earlier versions use the extension. Php3 and phtml). And just as HTML, the files are also saved as plain text files. (That means we do not need a special editor, a notepad. It should be remembered that not to create notepad line number we will need when debugging any problems with our code).

Comments
It is important to get used to write notes about your code with comment tags, so that our human nature to remember things can help if a need to review when you return codes you will ever make. How to make a comment that did not want to display or execution is to add "/ /" at the beginning of the line or flanking a comment with "/ *" and "* /" if necessary to make a long comment:
/ / This line will be ignored. Note to our own:
/ / Read a book, eating ice cream and playing games.
print ( "You are in Prothelon site!");
/ *
This one, also will be ignored.
And do not forget to come back to this site to view the article!
* /
?>

Code Syntax

Beginnings Code
All parts of the PHP code begins with "
End Code
Way to indicate that the PHP code is over is to add "?>" At the end of the code.

Line Labeling Program
In general, each instruction program ends with a semicolon ";". This means that although more than 1 line will still be considered one line instruction programs (see examples in parentheses explanation below).

Signs Brackets
In general, any PHP function will look like this ....
print ();
... in which "print" is the function and the things that needed doing these functions will be located inside the parentheses., and do not forget to end with a semicolon (error did not end with a semicolon is most common in beginners). Oh yes, before you forget, echo () also has the same functionality with print ().
Similar to HTML, the original of your PHP code (spaces, line changes, etc.) will not affect the output of the code which commands the browser on how to display your page. Thus, the following code ...

print ( "You are in Prothelon site!");
?>

... will produce the same thing to:



But it would be better to get used to using spaces and tabs to facilitate our long reading program.

11 komentar:

  1. wew, pakar PHP kayaknya nich... he he

    BalasHapus
  2. keyen php tutor, indonesia dunk wekekekek

    BalasHapus
  3. waktu kuliah dulu aku juga pernah dapat mata kuliah ini, tapi sekarang lupa .... hehe

    BalasHapus
  4. ilmu baru lagi nih sob mantap makasih ya sob

    BalasHapus
  5. WeW.. pinter ngo-prek PHP yaa.. mantaab.. keep posting sob.. btw komeng balik yaa...trus mana widget SHOUTMIX-mu ..www.shoutmix.com

    BalasHapus
  6. nice article... thanks infonya... dan slam kenal sob

    BalasHapus
  7. good day ...
    visit now expect a lot for commenting on our blogs, ask to exchange links because I am interested in some of the blog's content is here, for your attention Thank you

    BalasHapus
  8. wah boleh belajar dong,,ane jg lg pengen nyoba buat program aplikasi pake PHP :D

    BalasHapus