Jump to content


Photo
- - - - -

[php] - The Basics


  • Please log in to reply
2 replies to this topic

#1 Kev

Kev

    Young Padawan

  • Members
  • Pip
  • 21 posts

Posted 03 May 2005 - 06:50 AM

Well I'm not going to go in depth in this tutorial but I will show you the basics.
FIRST : Opening tag
<?php
this tag opens a php document, it tells the browser that when it reaches that string start reading as php. An alternative is [code[<?[/code] however some older php versions don't accept this and read is as a string of text. So it's safer to use
<?php
.

Ending tag
--------
Next is the ending tag.
?>
simple eh? That tells the browser to stop reading it as PHP code.

Variables
--------
A variable in PHP is just like a variable in Algebra (if you don't know Algebra it doesnt matter)
It has a value.
$variable=papa
that is an example of a variable, it assigns $variable the value papa. An example of how you could use this is
<?php
$variable=papa;
echo '$variable';
?>
That would echo the word papa on the page, notice after every php statement I put a ';' this is important as it tells the browser to end that statement.

Echo
-----
Notice in the above example I used 'echo', echo is a php function that "echos" something, in other words display it. you might see sometimes 'print', it is the same thing, how you use it is basically a matter of preference.

That concludes this tutorial, maybe later I might write a bit more indepth tutorial covering functions, mysql integration, and other things. Thanks.


this tutorial was made by someone on my staff. for more please visit www.kev-designs.com

#2 meadow

meadow

    Young Padawan

  • Members
  • Pip
  • 224 posts
  • Location:Devon, England
  • Interests:Php, Hockey, mysql, web design.

Posted 07 May 2005 - 10:31 AM

Cheers, I can't do too much php at the moment becuase ym server is being a bit odd.

#3 MaRmAR

MaRmAR

    Young Padawan

  • Members
  • Pip
  • 18 posts
  • Location:Slovakia

Posted 08 May 2005 - 03:07 AM

OK.
1) $variable=papa; should be $variable="papa";
2) echo '$variable'; should be echo "$variable"; because with apostrofes it wouldn't print real value of $variable but only "$variable" (but we want "papa")..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users