now we try to write our first code. Please copy the following code into a file (using notepad only), and write down what you want to display on the browser in between the quotes.
"Print" in the code below to display on the screen means web browser when you open the file:
Save the file with any name without spaces and ending with. Php (notepad users attention: when writing apitlah file name with quotation marks), and if you have installed the server on your own computer, you must save it in a special directory where the web root your server (if you use phptriad location is c: \ apache \ htdocs).
The next step is to open your first file in the browser. Type http://localhost/namafile.php to see your great work, and yes, you should see the words "you're on a site Prothelon" (do not use the file -> open, and do not forget to turn on your web server. For phptriad click phptriad -> start apache).
If you try the code on the internet web server, FTP your files to your web server root.
Come on, now try the first and make your code work. If it works, come back here and we're going to play again. (if not successful, just contact us).
Error Message
Fun is not it? Surely if successful, if not certain bete nih. Especially to see errors in the script. You very likely will get an error like this:
Parse error: parse error in http://localhost/namafile.php on line 12
This error message is very useful and you will meet many of these messages, error messages similar tuh same people who do not like it at us, continued to criticize his hobby, but if we use that criticism to improve, we can benefit. You'll get a message like that for every line of our code is wrong. For our needs, actually wrote we need to know is that there is a culprit in our code in line 12. The next step, of course, check our code. When this began to seem troublesome use notepad. Must count rows. Therefore try to use another editor, I myself like crimson editor. For our needs, we just need to know that something is wrong with our code in line 12, so let's look at the line soon they will be, and who knows may know the cause. I always start by looking at what my basic syntax is correct, for example if I had written; the end of the line, the closing tag, the parentheses?
Let us continue our code by adding some important part to the last page we had.
In the code that you write, please write a few lines again. As you can see, you can combine more than one PHP function in a tag. Comments in the code explain what each part:
NOTE: phpinfo will produce a very long information about your PHP version. You do not need to memeahami all means, I just wanted to show you. Who knows one day need it.
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.
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.
PHP Basics 2
What is PHP?
OK, the server is ready. The next question is the fact that what is PHP? PHP is a program installed on your web server software. PHP works on versions of the Apache Web server, Microsoft IIS, and other servers (in the case phptriad, web server used is Apache Web Server). PHP is easy to learn, (mosgoogle) you are using PHP with a way to insert PHP code into the HTML used to build your site. When a client (anyone on the web) to visit sites that contain this code, your server will execute. That's why you need to install your own server to test your PHP code locally. In this case, the server is not brain your browser. Browser functions to display only the work of the PC server to the client. The client does not require any special or additional to view your PHP code in action on the server for execution of PHP code you will be taken in the HTML code to the browser client. Said the clever, PHP is good because it does not spend resources on the server CPU.
PHP is a scripting language, just HTML. This means that the code does not need to be compiled before use. Code that we make will be processed as required. This differs from programming languages like C, VB or Delphi that needs to be compiled (meaning compiled in change from a text into machine language form that can be directly executed by a computer, typically the file extension is EXE). Consequently, PHP requires PHP server to execute PHP code is still in the form of text, while the program compiled the results in the form of executable files do not need another program to be executed.
Before you dig deeper, you need to know that there are sites called php.net. PHP is an open source language, and php.net is the central controller (imagine if no one coordination, will be very difficult development). Php.net has many reference materials on PHP and various tips that sent the programmers from around the world. PHP.net has a very good information and in-depth about PHP, but it would be very scary for beginners to jump in there. In addition there is material in advance. at the end of this tutorial we will discuss on how to use the php.net site.
OK, now we already know about PHP, PHP is able to make anything? this way, PHP is able to:
* Retrieving information from the web-based form and use it for various purposes (storing in the database, create pages based on content berkondisi form, send an e-mail, and others);
* Authentication and track visitors, which means that we can know that our site visitors prefer to see which pages;
* Serving a page vary depending on the browser usage or equipment (such as we can tell our site visitors pake IE or Firefox or PDA, and treated differently. Imagine if such a small screen PDA were given a standard web page that big?);
* Displays the entire page of our site using only a single layout. If the static pages, we must create a layout for one page;
Bottom of Form
But before we study the special use PHP, as usual, we need to start from the simple first. Beginning with how to create a block of PHP with the following simple script. Please write the below code (which is red) notepada pake only. Continue to save with the prothelon.php name. Do not forget when saving the file name box, name the file should be in quotes ( "prothelon.php") because if not so, then the extension will be a txt and the file name so prothelon.php.txt. This simple script will display the words "you're on a site Prothelon!" On your browser.
print ( "You are in Prothelon site!");
?>
The words in parentheses is the text that will be displayed by the browser, while the rest is PHP code.
Tag Is the beginning and end of the script, while the works you have to be placed in the middle. how, already understand? OK.
OK, the server is ready. The next question is the fact that what is PHP? PHP is a program installed on your web server software. PHP works on versions of the Apache Web server, Microsoft IIS, and other servers (in the case phptriad, web server used is Apache Web Server). PHP is easy to learn, (mosgoogle) you are using PHP with a way to insert PHP code into the HTML used to build your site. When a client (anyone on the web) to visit sites that contain this code, your server will execute. That's why you need to install your own server to test your PHP code locally. In this case, the server is not brain your browser. Browser functions to display only the work of the PC server to the client. The client does not require any special or additional to view your PHP code in action on the server for execution of PHP code you will be taken in the HTML code to the browser client. Said the clever, PHP is good because it does not spend resources on the server CPU.
PHP is a scripting language, just HTML. This means that the code does not need to be compiled before use. Code that we make will be processed as required. This differs from programming languages like C, VB or Delphi that needs to be compiled (meaning compiled in change from a text into machine language form that can be directly executed by a computer, typically the file extension is EXE). Consequently, PHP requires PHP server to execute PHP code is still in the form of text, while the program compiled the results in the form of executable files do not need another program to be executed.
Before you dig deeper, you need to know that there are sites called php.net. PHP is an open source language, and php.net is the central controller (imagine if no one coordination, will be very difficult development). Php.net has many reference materials on PHP and various tips that sent the programmers from around the world. PHP.net has a very good information and in-depth about PHP, but it would be very scary for beginners to jump in there. In addition there is material in advance. at the end of this tutorial we will discuss on how to use the php.net site.
OK, now we already know about PHP, PHP is able to make anything? this way, PHP is able to:
* Retrieving information from the web-based form and use it for various purposes (storing in the database, create pages based on content berkondisi form, send an e-mail, and others);
* Authentication and track visitors, which means that we can know that our site visitors prefer to see which pages;
* Serving a page vary depending on the browser usage or equipment (such as we can tell our site visitors pake IE or Firefox or PDA, and treated differently. Imagine if such a small screen PDA were given a standard web page that big?);
* Displays the entire page of our site using only a single layout. If the static pages, we must create a layout for one page;
Bottom of Form
But before we study the special use PHP, as usual, we need to start from the simple first. Beginning with how to create a block of PHP with the following simple script. Please write the below code (which is red) notepada pake only. Continue to save with the prothelon.php name. Do not forget when saving the file name box, name the file should be in quotes ( "prothelon.php") because if not so, then the extension will be a txt and the file name so prothelon.php.txt. This simple script will display the words "you're on a site Prothelon!" On your browser.
print ( "You are in Prothelon site!");
?>
The words in parentheses is the text that will be displayed by the browser, while the rest is PHP code.
Tag Is the beginning and end of the script, while the works you have to be placed in the middle. how, already understand? OK.
PHP Basics 1
Create their own Web site? Why not. For an entirely new in the world of PHP, this page is intended to arouse interest and enthusiasm to learn this language as a base for you who want to create a dynamic website. This page was created to introduce you to PHP.
Best regards and Enjoy.
This tutorial is intended for colleagues who newbie in the PHP world, but at least have to understand about HTML (please do not reply to learn HTML first, not complicated.
PHP is a scripting language that is very good and suitable to be combined with HTML. With PHP's ability to create dynamic websites and a beautiful design using HTML, then almost nothing that can not be done in both languages are combined in the world wide web. Good again, PHP is a language that is very easy (for those who never learned C or other programming language will greatly this difference. Example of one of the most feel the difference is that we do not bother at the beginning of variable declarations, if you need a variable to stay put).
Another advantage is that the language PHP is freely distributed open source alias, meaning there is a side benefit but can use for free that are available lots of good material about this language (one of them on this site), so once we understand the basics of PHP, will be very easy for us to develop our ability to remember so much material available anywhere.
You can also read an article about this PHP Learning to understand more deeply about what and why we need to use PHP. In addition, you may need time to yourself to learn strategies first learn PHP to understand the sequence suggested to learn PHP.
Before you begin, you need to install a server on your computer to try the script you created locally. (If you have space on a server that support PHP you can also try the script in there, but more complicated and costly because it requires FTP, Internet access, long, and so on). If you do not have the software to add functionality the web server, PHP on your computer, try searching on google keyword phptriad download, install on your PC wrote on. Kalo udah selesai install, restart Apachenya (if you already have MySQL database also turn on, continue to try to type in http://localhost when it addres out the Apache start page, it means that your PC is ready to try PHP. (Previously, the directory where we should put later files in c: \ apache \ htdocs, if not believe me, look wrote on index file in that directory with the same content that appears on the home page of our time access to the localhost).
Best regards and Enjoy.
This tutorial is intended for colleagues who newbie in the PHP world, but at least have to understand about HTML (please do not reply to learn HTML first, not complicated.
PHP is a scripting language that is very good and suitable to be combined with HTML. With PHP's ability to create dynamic websites and a beautiful design using HTML, then almost nothing that can not be done in both languages are combined in the world wide web. Good again, PHP is a language that is very easy (for those who never learned C or other programming language will greatly this difference. Example of one of the most feel the difference is that we do not bother at the beginning of variable declarations, if you need a variable to stay put).
Another advantage is that the language PHP is freely distributed open source alias, meaning there is a side benefit but can use for free that are available lots of good material about this language (one of them on this site), so once we understand the basics of PHP, will be very easy for us to develop our ability to remember so much material available anywhere.
You can also read an article about this PHP Learning to understand more deeply about what and why we need to use PHP. In addition, you may need time to yourself to learn strategies first learn PHP to understand the sequence suggested to learn PHP.
Before you begin, you need to install a server on your computer to try the script you created locally. (If you have space on a server that support PHP you can also try the script in there, but more complicated and costly because it requires FTP, Internet access, long, and so on). If you do not have the software to add functionality the web server, PHP on your computer, try searching on google keyword phptriad download, install on your PC wrote on. Kalo udah selesai install, restart Apachenya (if you already have MySQL database also turn on, continue to try to type in http://localhost when it addres out the Apache start page, it means that your PC is ready to try PHP. (Previously, the directory where we should put later files in c: \ apache \ htdocs, if not believe me, look wrote on index file in that directory with the same content that appears on the home page of our time access to the localhost).
PHP PROGRAMMING
PHP is a programming language that is relatively easy to learn because it is very flexible and does not require strict rules in the writing program. Well, to be able to learn at least you should understand some basic things first. We begin with the sequence of science that should be mastered first.
Ordering Learning PHP Programming
First, you must be familiar with the Internet. This is obligatory and mandatory, because PHP is a programming language intended for programming on the internet. Consider these examples have a dynamic website you browse and you would have seen that interactive web applications is very varied and useful. By looking at the many examples that exist, then you will be more creative
If you've used the internet, you must first understand the workings of the Internet programming. You can start by learning how a web page can appear on your computer screen from a web server that is located deep in the other hemisphere. One good source is w3school.org check that out!
Having no idea about how the Internet, you can start to learn HTML programming used to create static web pages. You need to master HTML view for the beauty of this web site are you going to make. Complete your knowledge with other disciplines such additional CSS that will make you easy to change the look of your website in a short time.
If it was mature enough in HTML, you've can start your walk to learn PHP programming. This will provide new capabilities to the web site that you created the interactive nature of the visitors your web site. As one source, you can learn php in the existing tutorial on this site.
Well, when you've started to learn PHP programming, you will get to a point where you will need a database. This database allows you to create your web site more useful again is to make you can save data to and from your web site visitors in large numbers and displays them more easily.
Ok, when it reached this stage, you've smoothly all the basic skills to create a web site. Next you stay honed skills you've got a lot of studying existing script. You can even create a sophisticated PHP programs without the need to write any code from scratch. Use an existing script to help you make web site development with PHP you much more quickly. hotscripts.com visit the web site as one of your sources, and in various forums aktiflah existing PHP.
Last ... practice, practice and practice.
Ordering Learning PHP Programming
First, you must be familiar with the Internet. This is obligatory and mandatory, because PHP is a programming language intended for programming on the internet. Consider these examples have a dynamic website you browse and you would have seen that interactive web applications is very varied and useful. By looking at the many examples that exist, then you will be more creative
If you've used the internet, you must first understand the workings of the Internet programming. You can start by learning how a web page can appear on your computer screen from a web server that is located deep in the other hemisphere. One good source is w3school.org check that out!
Having no idea about how the Internet, you can start to learn HTML programming used to create static web pages. You need to master HTML view for the beauty of this web site are you going to make. Complete your knowledge with other disciplines such additional CSS that will make you easy to change the look of your website in a short time.
If it was mature enough in HTML, you've can start your walk to learn PHP programming. This will provide new capabilities to the web site that you created the interactive nature of the visitors your web site. As one source, you can learn php in the existing tutorial on this site.
Well, when you've started to learn PHP programming, you will get to a point where you will need a database. This database allows you to create your web site more useful again is to make you can save data to and from your web site visitors in large numbers and displays them more easily.
Ok, when it reached this stage, you've smoothly all the basic skills to create a web site. Next you stay honed skills you've got a lot of studying existing script. You can even create a sophisticated PHP programs without the need to write any code from scratch. Use an existing script to help you make web site development with PHP you much more quickly. hotscripts.com visit the web site as one of your sources, and in various forums aktiflah existing PHP.
Last ... practice, practice and practice.
Langganan:
Postingan (Atom)