![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | ||
|
Hobbyist Programmer
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5
![]() |
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. php Syntax (Toggle Plain Text)
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. php Syntax (Toggle Plain Text)
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: php Syntax (Toggle Plain Text)
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 Last edited by big_k105; Nov 16th, 2007 at 9:24 AM. Reason: Changed the quote tags to php tags. |
||
|
|
|
|
|
#2 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
Nice tutorial.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower |
|
|
|
|
|
#3 |
|
Programmer
|
yeah, ditto, read the whole thing
![]() |
|
|
|
|
|
#4 |
|
Programmer
|
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
|
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 8
![]() |
Download what?
|
|
|
|
|
|
#6 |
|
Programmer
|
phptriad, i found about 200 mirror downloads and finally got one, never mind
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Nov 2004
Posts: 1
Rep Power: 0
![]() |
I don't mean to be a pest, but I wrote all three of these php tutorials at another forum :mellow:
|
|
|
|
|
|
#8 |
|
PFO Founder
![]() ![]() |
i have pm'ed you.
__________________
BIG K aka Kyle Programming Forums Kyle K Online Please do not PM or email me programming questions. Post them in the forums instead. |
|
|
|
|
|
#9 |
|
Programming Guru
![]() ![]() ![]() |
credit not given where credit is due?
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#10 |
|
Newbie
Join Date: Feb 2005
Posts: 1
Rep Power: 0
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Php Tutorial 3 | bulio | PHP | 4 | Jul 16th, 2006 4:00 AM |
| Assembly tutorial, part one. | Mad_guy | Software Design and Algorithms | 21 | Apr 15th, 2006 7:02 PM |
| Basic HTML Tutorial - Reuben Keeney | ReubenK | HTML / XHTML / CSS | 14 | Mar 26th, 2006 5:50 AM |
| Tutorial - Using MySQL in C# | Darkhack | C# | 12 | Jan 17th, 2006 9:28 AM |
| [tutorial] Simple G++ compiler tutorial | coldDeath | C++ | 7 | Nov 27th, 2005 12:33 PM |