![]() |
Php Tutorial 1
<?php
Hey, this tutorial is meant to give you information on setting up php, and writing your first scripts. Have fun. I plan to release more tutorials, with more advanced scripting, but it's the basics first, so make sure you read it B) I recommend HTML knowledge. PHP: What is it and how do I set it up? PHP stands for pre-hypertext processing language. This means that all the code is read before the web page is submitted. PHP is considered the most powerful web-language and is used to develop most modern sites. It can be used to create things as simple as a tagboard, and as advanced as a complete portalling system. To set up PHP is simple. First you will need a host with php and mysql support, or you will need your own server, I would suggest downloading phptriad from download.com for this. It comes complete with MySQL, php, and folders needed. I have my own server, now what do i do? (If your using a host discard this information) Now you need to unzip it to a main directory on your computer, which is most likely your C:/ Drive. Now I want to go how you will have to save now, so explaining things later will be easier. Open up the server folder, and find the folder htdocs. This is where you will save all of your php documents, otherwise your php scripts will not work. Also, when testing your php scripts, you will have to insert this into your browser's url box: localhost/nameoffile.php ALSO, make sure you turn your Apache server on, otherwise your scripts will not appear. I've got some type of server or hosting that supports PHP, now what? Now I think your ready for your first script/s. Open up notepad or another text editor, and insert the following code. The comments (/* blah */ Are not required. :
Now, I think you know the output of this one, but before we get to that, let's see how we save our document. If your using a hosting server, simply save it as whatever.php, and make sure a drop down menu says either HTML document or PHP document. But if your using your own server, find the drop-down menu that says "text-file". Click it, and then select "All Files". Now save this as whatever.php. Now to view it, in your browser, type the url location. ex: Quote:
Quote:
Great, now you've done your first PHP script! Exciting? I doubt it, that is probably one of the most used command (echo) you'll ever use, but it's completely useless to use without other things! But first, let's explain what was in the comment tags. <?php and ?> are your PHP delimiters. Everything in these tell the browser that it is a php script, they are required. The echo command simply let's the browser know that text, or something else is being displayed. Also in the single quotes you can add HTML tags. Such as <b> if you want bold text. Also good practice for including HTML tags into your quotes is adding backslashes before your true quotes in your tags. Ex. :
Now let's look at the last part of our Introduction, variables. I think you will find variables to be the most important factor of PHP, they save time, help with scripts, and so on so on. First, what is a variable? A variable is something that can be changed. Let's say we had a website that managed a company, and the admin's name was Jake. Now Jake's name appeared all over the website as an admin in hundreds of pages, but the admin changed. It would be very tedious to change Jake's name to the new admin's, so it would be much simpler to include the admin name in a variable, and change it when needed. Let's see: :
Now, save this, open it up, and see the magic of variables. If done correctly, where your $name variables were, there should be the name you specified within the variable. You can change this to whatever you want, and both text areas would display the new name. See how this can make life easier? Now test with variables and so on by yourself, see what you can come up with just by knowing echo and variable commands. Look forward to Part 2 of the php tutorials, where you will learn much more scripting knowledge. ?> Created by Syringex |
Nice tutorial.
|
yeah, ditto, read the whole thing :(
|
I went to download it off download.com and when i clicked it and it said "your download is in progress right now" it doesnt pop up, and i cannot download it
|
Download what?
|
phptriad, i found about 200 mirror downloads and finally got one, never mind
|
I don't mean to be a pest, but I wrote all three of these php tutorials at another forum :mellow:
|
i have pm'ed you.
|
credit not given where credit is due?
|
hey guys
I am novice to PHP. Will you please guide me to learn PHP Waiting for your reply. you can reply me on ypsonaje1@yahoo.co.in |
| All times are GMT -5. The time now is 2:12 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC