FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

PHP Toturail

 


alone
Have you ever wanted to have dynamic pages, move data more powerfully, or make maintenance easier? Well, a great solution is PHP


PHP is a recursive acronym for Hypertext PreProcessor. It is a general-purpose scripting language for use on the Internet and it can be embedded into HTML.

PHP is a server-side scripting language. This means that the scripts on the page are parsed by the server before they reach the browser. Therefore, if you view the source of the page, you won't see the PHP code. Average users won't even know you are using it, and it is imposssible to steal your code unless a person has direct access to the server.

Getting ready to use PHP
Because PHP is a server-side language, you must have a host that supports it in order to use it. Most hosts support PHP. However, you can run your own local Web server on your computer to test and learn PHP. You simply download a free Web server, such as Apache or Xitami and follow their instructions for setup. You also need to download the PHP package for your operating system. I also suggest you download the PHP reference documentation. It will come in very handy. After installing PHP and a Web server, you are ready to make your first program.

Writing PHP Code
PHP code is inserted directly into your HTML page at any place. PHP code goes between these tags:

<?php ?>
A simple page would look like this:

<html>
<body>

<?php
echo('<h1>Hello World</h1>');
?>

</body>
</html>
To try this out, open Notepad, or any simple text editor. Do NOT try to use Word or anything similar as it will try to convert your code. Then save the file with a .php extension. Note that this isn't an executable file. It acts as a regular HTML file, except the Web server is set to parse the PHP code. You can view this file by turning on your server, and placing the file in the root directory. Then type http://localhost/ into a browser and navigate to the file.

This script simply prints the words Hello World at heading 1 size on the page. You wouldn't need PHP to do this, it is just an example. Note how HTML tags can be placed in the echo.

Variables
The previous code can also be written using variables. Variables, like it algebra are a letter or word (that can contain numbers) that represents something else. The previous code can be written like this.

<html>
<body>

<?php
$a = '<h1>Hello World</h1>';
echo($a);
?>

</body>
</html>
This puts out text in a variable and prints the variable. Variables can also be added, subtracted, multiplied, and divided.

<html>
<body>

<?php
$a = 2;
$b = 10;
$c = 5;
echo($a * $b / $c);
?>

</body>
</html>
The above prints out 4 (2 times 10 divided by 5).

Easy Maintenance With PHP
Regular site maintenance can be a pain if you have to change even one link on every page. PHP can make these types of situations much easier by allowing you to edit one file and change multiple pages. This is done through the use of includes. An include brings one page into another page. For example, say we have this basic page:

<html>
<body>

<div id="nav">
<a href="link1.html">Link 1</a><br>
<a href="link2.html">Link 2</a><br>
<a href="link3.html">Link 3</a>
</div>

<div id="content">
Content here...
</div>

</body>
</html>
To make maintenance easier, we could include the navigation into every page. To do this we put the nav in a separate .php file.

<div id="nav">
<a href="link1.html">Link 1</a><br>
<a href="link2.html">Link 2</a><br>
<a href="link3.html">Link 3</a>
</div>
Then we'll name this nav.php. Then we replace the nav in the our basic page with a PHP include statement.

<html>
<body>

<?php include('nav.php'); ?>

<div id="content">
Content here...
</div>

</body>
</html>
Now the nav.php file is substituted for the include statement by the server. If you view the source, the page will look normal, because the server brings in the nav.php before it ever reaches the browser. Now simply add that statement in place of the nav on every page, and you only have to edit the nav.php to change the nav on every page. This is a wonderful time saver.

And now you are off to a great start to utilizing PHP on your own site.
gamego
Do you have any site that teach PHP step by step?I want to learn it.Thanks in advance.
WickedGravity
can get a great tutorial from the same place he copied and pasted this one from.

http://www.designertoday.com/tabindex-19/tabid-38/DesktopDefault.aspx

Haven't you copy and pasters ever heard of Google? I mean, it isn't all that hard to find out where you got this.

There must have been ten sites where this same thing was, which means some other spammer candp'ed it over there.
SamiTheBerber
Visit http://www.w3schools.com/. There you will find good tutorials for PHP and all subjects of web programming ...
simplyw00x
Next time, try the following:


  • Don't copy and paste, then pretend it's your tutorial
  • Learn English before posting on an English forum
  • Spell 'Tutorial' the correct way. Not too difficult, seeing as that's what this board is called...
  • Add either a link to where you got the tutorial or, well... anything
jacknanet
someone could show me a link that haves a advanced PHP tutorial?

i need some good tips...
snowboardalliance
Best tutorial I found, http://www.hudzilla.org/phpbook/index.php
markgil
ok here u can learn manual php tutorial go to the link site

http://www.php.net/manual/en/install.windows.php
http://us3.php.net/tut.php
http://www.freewebmasterhelp.com/tutorials/php
techcheetah
Which is the best book to learn php....

And i've heard that PHP is much similar to C. Is that so ??
Guess who
Yeh i dont get how to use php either i just try to learn how to use it by reading stuff off google Laughing
Guest
Hmm...there are plenty of tutorial sites around. Unfortunately, when you search for them under a specific topic (e.g: creating email forms)using Google, it seems that you don't really get the one that you want. I've tried narrowing down searches, but that doesn't work. @.@
Neus
Oh thanks for the links and the mini tutorial at the top Smile

I'm thinking of buying a book on PHP sometime soon... any books you know of that are great? i dont want one that dumbs it down too much, i know what im doing Wink i just need something for someone who understands stuff fast... and i dont want something too advanced that leaves me clueless as to what in the world it is doing cause it doesnt explain anything...
anjodamorte
Oh thanks for the links and the tutorial
coolpages
this info is really helpfil
thanks for posting it
techcheetah
Where can i find PHP GD Library tutorials..

plz help ??
aytac
Great links thanks all
capitalmail
thanks
Antoine_935
tutorials are cool.
but I think the best way to learn a programming language is books, because you can access it whenever you want.
Tutorials, you must have an internet connection. and at 02h00, when you get a gret idea, you don't always have this connection...

definitively, to effectively and quickly learn a programming language, you need a book.
liam_uk7
Some of the links in the post are extremely helpful. I have looked around for a while but never really found anything this good and helpful. Thank you. I usually just use a CMS but am looking to make my own layouts. Does anyone know any links to sites that show you how to code a layout or graphic. Thanks.
aloSegun2
This one is a good tutorial and step by step:
zend.com beginners only
Reply to topic    Frihost Forum Index -> Miscellaneous -> Tutorials

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.