|
php tutorial with examles |
|
|
|
|
Written by zadminz
|
|
Saturday, 15 August 2009 21:43 |
|
Page 1 of 68 Learn PHP The essentials for learning PHP: Learning a new language (programming or otherwise) can be a bit overwhelming. Many people just don't know where to start and give up before they even begin. Learning PHP is NOT as overwhelming as it might seem, I promise you. Just take it one step at a time, and before you know it you'll be off and running. 1.) Basic Knowledge: The first thing you need, before you start learning PHP, is a basic understanding of HTML. You can switch between PHP and HTML right in the same document. You can even run PHP from an HTML file. 2.) Tools: When creating PHP pages, you can use the same program you use to create your HTML pages. Any plain text editor will do. You will also need an FTP client to transfer files from your computer to your web hosting. If you already have an HTML website you most likely already use an FTP program.
3.) The Basics: Now you can finally get started learning PHP! The first thing you should read is our PHP Basics tutorial. This will take you through creating your first file, using variables, basic math, and basic IF statements (a form of logic). 4.) Learning Loops : Once you have mastered these skills, it is time to learn about loops. Loops repeat the same actions over and over again until a condition is met. There are several different types of loops which are explained in our Learning Loops tutorial. 5.) PHP Functions: Finally, you can learn to write your own custom functions. From here the sky is the limit... With a solid knowledge of these PHP basics, adding PHP functions to your arsenal when you need them will be easy. Now What?: Where can you go from here? Our step-by-step tutorials show you how to put these PHP skills to use, by making practical scripts for your website. What is PHP?PHP BasicsPHP LoopsPHP FunctionsAll Begining PHP ArticlesAll Advanced PHP Articles Learn PHP - A Beginner's Guide to PHP Programing From Angela Bradley, Your Guide to PHP / MySQL. FREE Newsletter. Sign Up Now! Basic PHP Syntax PHP is a server side scripting language used on the Internet to create dynamic web pages. It is often coupled with MySQL, a relational database server that can store the information and variables the PHP files may use. Together they can create everything from the simplest web site to a full blown business web site, an interactive web forum, or even an online role playing game. Learn more about PHP. Before we can do the big fancy stuff we must first learn the basics from which we build on. 1.Start by creating a blank file using any program that can save in plain text format. 2.Save your file as a .PHP file, for example mypage.php.
Saving a page with the .php extension tells your server that it will need to execute the PHP code. 3.Enter the statement <?php to let the server know that there is PHP code coming up. 4.After this we would enter the body of our PHP program. 5.Enter the statement ?> to let the browser know the PHP code is done. Every section of PHP code starts and ends by turning on and off PHP tags to let the server know that it needs to execute the PHP in between them. Here is an example: <?php //on //and //off ?> Everything between the “?”s is read as PHP code. The <?php statement can also be phrased as simply <? if desired. Anything outside of these PHP tags is read as HTML, so you can easily switch between PHP and HTML as needed. This will come in handy later in our lessons. Comments If you want something to be ignored (a comment for example) you can put // before it as I did in our example on the previous page. There are a few other ways of creating comments within PHP, which I will demonstrate below: <?php //A comment on a single line #Another single line comment /* Using this method you can create a larger block of text and it will all be commented out */ ?> One reason you may want to put a comment in your code is to make a note to yourself about what the code is doing for reference when you edit it later. You may also want to put comments in your code if you plan on sharing it with others and want them to understand what it does, or to include your name and terms of use within the script.
|
|
Last Updated on Monday, 23 November 2009 12:41 |