My First Php Tutorial - What is PHP?

Pages: 1, 2, 3
free web hosting

Read Latest Entries..: (Post #21) by iGuest on Dec 19 2007, 05:40 AM. (Line Breaks Removed)
I'm trying to set Adsense ads and a Google search box on my website (php-nuke) and I'm having problems. I don't know where to paste the code, in which files.I'll appreciate any help.Cesar MartinezWww.Cmads-4life.Com-Cesar
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Tutorials

My First Php Tutorial - What is PHP?

ghostrider
This is my first attempt at writing a PHP tutorial. Its from a while ago. What do you guys think?

Intro To PHP
Tutorial 1 - What is PHP?
Released 2/20/07
By Chris Feilbach aka GhostRider

Contact Info:
E-mail: assembler7@gmail.com
AIM: emptybinder78
Yahoo: drunkonmarshmellows
Website: http://www.ghostrider.trap17.com

Hello, and thank you for choosing my tutorial. If you are completely new to PHP, this tutorial will teach you all the basics, and if you are not it will serve as an excellent reference for you. I will release the next section of my tutorial every 1 to 2 weeks. All of the basics will be covered; in this set of tutorials you will learn everything a PHP coder needs to know, including how to use MySQL (a database server), and how to handle data from forms. If you want to learn about something in particular, go ahead and contact me and I will see what I can do. You also should contact me if you have any questions about anything I write in my tutorials.

You should know HTML before you read my tutorial. If you don't PHP has no use to you. Go learn it and then come back. It does not take long to learn how. http://www.w3schools.com is a great resource.

PHP stands for Hypertext Preprocessor, which is a bunch of big words that means it runs a script, or a bunch of PHP that you write, and then outputs something to the person viewing your web page. PHP is very powerful; it can output more than just HTML. You can also create images, and various other things using PHP and output them to your user's browser.

PHP is a server-side application, meaning that all of the processing is done on the server, or the computer that sends the data to your user. Things such as HTML and JavaScript are client-side applications, meaning that the code is sent to the computer viewing it and then processed. The fact that PHP is server-side means that any computer with a web browser can view its output.

PHP requires a server, such as Apache, to run. I run all of my scripts that I make off of my website. You can either get webspace that supports PHP (www.trap17.com is where I get my totally free webspace), or simply download your own webserver on your computer. I don't have a preference for a server for testing PHP. Anything that supports it will do.

PHP files are placed in the same directory that your html files and other files are stored. For my site, I place them in the public_html. PHP files can be written in ANY text editor. I primarily use Linux, so I use KWrite to write my PHP files, but Notepad is probably the best editor for Windows. I prefer KWrite over Notepad because it color codes your PHP, making it much easier to read, and also displays line numbers if you press F11, a feature that makes debugging PHP much easier.

I have been programming in a variety of languages for 10 years now, and every other decent programmer will tell you the same as I am about to. Take small steps with learning ANY language, don't be discouraged if it doesn't work right away (it usually doesn't when your new to it), and enjoy your success. Show some creativity with your work and make it yours. Have some patience at first, as I said above, things won't always work the first (or second, or third, and so on) times, especcally when your new. If worst comes to worst e-mail me your code and I'll help you out the best I can.

Now that you've listened to all of that, I think its about time we actually coded something. First we need to learn a little bit about the syntax of PHP. I'll walk you through it step by step.

First, to tell the server that we are beginning PHP code, we need to put this.

CODE
<?PHP


The server is now proccessing PHP. You no longer can just write HTML, you will cause an error if you do. To send stuff use the print() or echo() functions. Both of them do exactly the same job.

CODE
print("PHP is awesome!");


This command sends PHP is awesome! to the user's web browser. "PHP is awesome!" is something called an argument, or something that a function needs to do its work. You need to place strings, or things with characters, in quotes "". End it with a parenthesis, and use a semi-colon (wink.gif to tell PHP that it had reached the end of the line. YOU NEED TO DO THIS FOR EVERY LINE OF CODE, OR YOU WILL GET AN ERROR.

You can include HTML markup inside of the print() or echo() function. For example:
CODE
print("<br><font color=red>Red is my favorite color.</font>");


Will print out Red is my favorite color., in red.

End your php code with this:

CODE
PHP?>


I have one more thing to introduce to you today. You can add comments to your code to help yourself and other people that read it understand it. Anything that follows two forward slash marks (//) is considered a comment. PHP will not consider them code.

The whole thing looks like this:

CODE
<?PHP
print("PHP is awesome!"); // The two lines mean that this is a comment.
// PHP completely ignores //.  Commenting your code is very imporant, so do it!
print("<br><font color=red>Red is my favorite color.</font>");
PHP?>


Have some fun with this. Print whatever your heart desires. Next tutorial we will go into variables, and shortly after that we will cover forms.

Happy coding!

 

 

 


Reply

JSPICE85
Cool... that tutorial is for me!!! hehehe.. I need to lear PHP and I need it fast! smile.gif

Reply

shadowx
Nice tutorial there, I like the fact it really does build from the ground up to help people who have never even heard of PHP before. Did you ever write any follow-up tutorials? If you did then you should post them here, you get credits and we got something to read that can help us out! Win-Win situation!

QUOTE
You should know HTML before you read my tutorial. If you don't PHP has no use to you.


True words! Although PHP isn't that hard to understand, without HTML it truly is useless!

Keep up the good work

Reply

Sprnknwn
It's useful for begginers, sure. There are lots of people who wants to start with php and don't know where to begin because there are so much tutorials for advanced programmers...

Reply

matak
Also it should be noted that PHP is OOP language!

Reply

Kevin5555
Very nice guide, I like it. and i unserstood basicly everything i wasnt like huh.gif when i read it, like i'm usually is. Going on to part 2 now

Reply

srujanlive
very good man. Thank you very much. Continue your lessons

Reply

JDameron91
Nice, should help some of the newer users of PHP. I like how you brought out that echo(); and print(); do the same thing, that was something confusing for me when I started.

Reply

xoverclockerx
Just what I needed smile.gif thnks

Reply

hibbso
like???? WOAH!! I can (sorta) PHP now!!! Thankyou very much ghostrider!!!! It took me nearly a year to look through the internet to find php tuts that i can understand. Then a bloke says go to topic biggrin.gif. Im gunna make you famous lol.

once again. Nice tutorial(s). (i read your others)


EDIT:

By the way didnt you say a tut will be released every 1-2 weeks?

Reply

Latest Entries

iGuest
I'm trying to set Adsense ads and a Google search box on my website (php-nuke) and I'm having problems. I don't know where to paste the code, in which files.

I'll appreciate any help.

Cesar Martinez
Www.Cmads-4life.Com

-Cesar

Reply

html
Really magificent.

Reply

Daaneo
Thanks this really helped me now i want to learn PHP

Reply

vivalove
Wow. That's useful. Thanks.

Reply

abminara
Thank you very much, although, I knew these basics anyway. In the next tutorial please try going deeper and discussing specific operators, but DO NOT give the whole code ready for the webpage - I'll be too lazy to learn anything:P

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2, 3
Similar Topics

Keywords : php php


    Looking for php, php,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for php, php,

*MORE FROM TRAP17.COM*
advertisement



My First Php Tutorial - What is PHP?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE