You are using a browser which is not compatible with CSS (for more information, see Tara's tutorial). Because of this, it is possible that our website may not appear correctly in your browser. We apologise for the inconvenience, and recommend you upgrade your browser to one which is compatible with CSS. For more information, please visit our Browser Upgrade page.

4WebHelp

PHP Basics by Tara

Last updated: 02/09/2004
Biography: Tara has finished studying Indian religions and is now working as a project manager in Biel, Switzerland. When she's not at the cinema, hanging around with friends, or throwing people around on a judo mat, you'll probably find her tinkering on her website and spending many an hour chatting with online friends all over the world.
See 1 more tutorial by Tara

<html>
<head>
<title>4WebHelp - <? print ($pagetitle); ?></title>
</head>
<body>
Menu Link 1
Menu Link 2

<? print ($contents); ?>

</body>
</html>

Comments on this tutorial
Name: AnizaEmail anizot at gmail dot com
what programs do I need to start using php?
Name: AnizaEmail anizot at gmail dot com
Hi, I'm used to using html but found out that using php is much easier.  I don't understand how to start using php.  I've been using microsoft frontpage for my html editor, editing my webpages and then uploading them to the server.  How do I change from using .htm to .php??  You can look i my site at http://www.triumphvillage.com

thanks
Name: DanielEmail use contact form
la: I'm sure that having figured out comment spam, PHP will come easily to you. Wink
Name: laEmail none
i inserted this code ][   <?php require ( "nav.inc") ; ?>][ into the html file.
But how can php be executed, if your browser doesnt read php and there is nowhere in the script a reference line that tells php where to look to execute the script?
It will maybe be a stupid question - that'sbecause I still don't get the real basics of the working of php.
[Spam deleted]
Name: James MaynardEmail jgmaynard at yahoo dot com
OK, It made some sense at first, then got too bogged down in examles for me. I can do HTML all day long (I do!) and have taken a course in C++, etc., but I'm completely lost.
What I would need would be a SIMPLE example with steps listed one by one.
1) take the following code. 2) Put it into an HTML file caled name.html 3) sent to server, or whatever. Just my two cents.
Name: CraigEmail none
I think this is a great intro to PHP.  Im a complete beginer trying to work on an OScommerce template - this has explained a lot to me.  Thanks
Name: PatrickEmail none
Thanks Tara, That was a big help. I read some of the other comments and I am disappointed with some of them. Newbies like me owe a lot to people like you that take the time to help. Thanks again-Patrick
Name: JohnEmail john754 at aol dot com
Very nice site!
Name: RyanEmail ryyz2004 at yahoo dot com
if anyone can help me talk to me on msn messenger ryyz2004@yahoo.com Thanks
Name: Roger BurgessEmail none
<?php

$email = "you@yourdomain.com";

if (eregi("googlebot",$_SERVER['HTTP_USER_AGENT']))

{

mail($email, "The Googlebot came to call",

"Google has visited: ".$_SERVER['REQUEST_URI']);

}

?>

<?

Works
Name: Thomas TallonEmail animationplanet_uk at yahoo dot co dot uk
please help that is so confusing and i want to learn it so much i can do html but php is as hard as lerning everthing in the world i need help please email me ether to help or if u carnt do it and u want to meet some one who also carnt so we could help each other

thanks !!
Name: BennyEmail Benny at Slipflip dot com
I am totally lost in this... If this is the simplest way to explain it, i'm screwed... Anyone who can help, please send me an e-mail Smile
Name: RAJEEVEmail raj_tripple at yahoo dot com
its ok for the beginers. aslo the article can be beautified by adding the some information about why need php?
Name: JimEmail none
This tutorial is alright. Expand it so that it would be more useful
Name: AimeEmail abrittain at hotmail dot com
Still dang lost.... you are speaking French to me. I have no clue about what you are saying. .... Damn I am going to have to pay someone to do this. I was trying to avoid this at all cost.


Name: DaNzaEmail relentless_1988 at hotmai dot co dot uk
Iam so lost with the whole php code! Html and css no probs, but php is just hell at the moment!!! CAN ANYONE HELP ME?
HELP!!!!
Name: WoadEmail woadraiders at hotmail dot com
Not working for me at all. I tried <? and it didn't do anything, I tried <% and it changed color but that was it.
Name: Rebecca K.Email none
Hey thanks SO much! I can do HTML in my sleep but I had trouble wrapping my mind around PHP - this broke the barrier. Now I can start USING it. Thanks!
Name: EikEmail none
Difficult....
But I realize that I can do a lot of sh*t on the net with php code... ;p
Name: KrystofEmail none
Thank you for explaining [b]there is no need to name an include file ".inc"[/b]. I am converting from SSI to PHP. Now I don't have to change my include files from [b].htm.[/b] And a nice clear introduction to PHP all around. I will post a link from www.Kwik-n-free.com.
Name: BrendanEmail test at kampok dot com
I want to place basic text advertisements on my website, but I want to be able to change them frequently.  I have so many pages, I was wondering if I could place a php script in each page which would enable me just to modify one page instead of all of them
Name: aviEmail none
thats a great work.. it really helped.
thanks
Name: Jacob PilegaardEmail miuer at yahoo dot com
Great introduction, I wish other introductions could be as precise and clear as this.
Thanks Jacob
Name: NintendudEmail none
Thanks a bunch for the basics! I was searching around for a small introduction and this did the trick. Now I can start reading my book on PHP. Yay!
Name: yanieEmail ysrwd at hotmail dot com
can any one tell me how to create cms i really really new to php
Name: Dave WaltersEmail goldwingers at usa dot com
Thanks Tara. This has really helped to get a basic understanding of how PHP mingles with HTML. Am just beginning down the PHP path. Appreciate your information.
Name: Dave WaltersEmail goldwingers at usa dot com
Thanks Tara. This has really helped to get a basic understanding of how PHP mingles with HTML. Am just beginning down the PHP path. Appreciate your information.
Name: sureindEmail none
iam new to php plz give tutorails
Name: surekumarEmail sureind2003 at yahoo dot com
hai
iam new to php programming can bring some
useful sites url
Name: dawa sonamEmail none
I m getting a grasp on PHP now
Name: PipEmail none
i dont understand a word you just said



hel;p
Name: AmitEmail dtph10 at yahoo dot com
What are .tpl files and how are they different than .php files
Name: seems to do the trickEmail none
<html>
<body>

<?php require("header.htm"); ?>
Name: actuallyEmail none
actually it works for some things and not others

whats the best way to make a template file

and then put html into in?
Name: sameEmail none
<? echo ($reviews); ?>

seems to do it

unless there is a better way

Name: hiEmail phpq dot 5 dot qqq at antichef dot com
can someone tell me how store html tags in a PHP varable

for example

<?
$reviews = "<br><br>some html here <a href="whatever.html">agff</a>";
include ("temp.html");
?>

etc

i understand that varables are not for this
but how is it done

thanks I am very new
Name: Reshma ReddyEmail none
This site is very useful for the beginners
Name: viksraEmail viksra at gmail dot com
Thanks for helping me get one step closer to becoming a billionaire.
Name: JMEmail none
OH Yes!

This is what the world has been waiting for  - Thanks Tara
Name: SusanEmail none
Thanks a heap for this well-written tutorial!  I've been exploring PHP for several days and really find it useful.  I've been using several of these bits of code without knowing what they really mean.  
Name: MoeEmail none
Hey man thanks a lot for taking the time to put this together. I feel a lot more confident that yes, I CAN do this! Cheers Wink
Name: DanielEmail use contact form
Greg: The page's filename has to end with ".php", not the actual contents Smile. Also, in the code you posted, you should remove the "<?" at the end.
Name: GregEmail Sales at BetchaBoots dot com
Thanks for keeping it simple.  I just received a bit of PHP code to add to my website to tell if a spider has visited.  It said to end the page with
.php
but it kept showing up on the published page.  I believe from your examples that
?>
will do the job.

Here's the code if anyone is interested.


<?php

$email = "you@yourdomain.com";

if (eregi("googlebot",$_SERVER['HTTP_USER_AGENT']))

{

mail($email, "The Googlebot came to call",

"Google has visited: ".$_SERVER['REQUEST_URI']);

}

?>

<?



Thanks again
Name: JakeEmail none
Cheers,
Ive been looking through a load of PHP guides all day but none of them had the basics!
Name: CasperEmail none
Thanks for the quick introduction!
Name: lakshmanEmail lakshman553 at hotmail dot com
now i came to know php is really cool!
Name: DanEmail dan dot dilts at cexp dot com
Thanks. I have been saved!
Name: DanielEmail use contact form
figidigi: Your file's extension has to be .php Wink
Name: figidigiEmail figidigi at showerzone dot nl
Hi there,
this is the first page that I find which is written clearly. I made notes and all to understand the stuff. I am a veryvery newbee at php , i bought a book, but still cant figure somethings out.

Still I have a few questions, hope thats okay...

My server has php dev installed. I myself did not install anything. I wrote a testfile according to your tutorial.
test is on: http://www.showerzone.nl/test/testphp.htm

i inserted this code ][   <?php require ( "nav.inc") ; ?>][ into the html file.
But how can php be executed, if your browser doesnt read php and there is nowhere in the script a reference line that tells php where to look to execute the script?
It will maybe be a stupid question - that'sbecause I still don't get the real basics of the working of php.

hope u can help me out.
thanx - figidigi
Name: DanielEmail use contact form
<?php
header('Location: http://www.site.com/');
?>
will redirect visitors to the location of your choice.
Name: FayezEmail fayez2 at yahoo dot com
First .. I am new to PHP so do not lough!
I am writing a script in which it should transfer to another web page under certain condition. I know in ASP that I can use redirect statement but I would like to know about that in PHP.

Thanks
Name: matejEmail none
Thanx this tutorial really helped me...
Name: MathewEmail mathew_manuel1 at mailcity dot com
Tara thanks for this wonderful Tutorial
Name: Somsak WisitwatanawongEmail oagrsws at ku dot ac dot th
Thanks for your generosity, introducing the features of PHP to those guys lost in web info, including me.

Add a new comment

This page is © Copyright 2002-2010, 4WebHelp. It may not be reproduced without 4WebHelp's prior permission.