Heya webmsaters..

ive seen a few of you the are oblivious to php so im going to starts a tutorial / guide for you all

Ok so lets begin
______________________________________

Tutorial Info:
Name: Simple Functions.
Level: Basic.
Writer: Cornetofreak

ok so im going to start by explaining the most popular but the most basic functions you will come across whilst creating your script/software.

1.

The first function ill be talking about is the "echo" function, this function is used to print a string of information to the web users screen.

Example:
PHP Code: 
<?php
      
echo 'FooBar';
?>
by placing this block of code into a file called Foo.php and then running the file on your server will show the word "FooBar" and nothing else.

2.

The second function ill be showing you is the "print()" function, nor comparing this to echo theres not alot of difference but a few little things

echo is not actually a function where as print() is and because it act's like a function it will then return data so echo is actually faster

PHP Code: 
<?php
      $ret 
= print("Hello World");
if your on a basic level of php then you would assume that the value of $ret would be a string of "Hello World".. this is where you would be wrong.

$ret would have the value of 1, this is because print() can be used as part of a more complex expression where echo cannot.

so it is always advisable to use "echo" to print strings to the screen and there's no need to use "print()"

Now ill be showing you how to use the "if(){}" statement.

if statements are one of the most commonly used in creating a script.
all programming languages are built around the one thing that we have in common with other humans and that's logic

logic is hard to explain but we use it in everyday life.. below are some examples of how you would use logic in your normal day and then ill change into the program form..

Human Form:
If you want a piece of toast then shout to your mom

How i interoperate this:
If (you want a piece of toast) then {shout to your mom}

Program Version:
PHP Code: 
<?php 
$You_Want_Some_toast 
true;
if(
$You_Want_Some_toast){
     echo 
'Mom can i have some toast';
}
?>
as you can see that programming can be easy if you relate it to something you know so well..

if statements basic check the expression you give with the braces so here are some more examples of if statements.

PHP Code: 
//Example 1.
if(true){
      die(
"I was true");
}

//Example 2.
$foo true;
$bar false;
if(
$foo !== $bar){
     die(
"Foo is not exactly the same as Bar");
}

//Example 3.

$value1 20;
$value2 20;
$answer 40;

//Ok so we know if we do this 20+20 this would equal 40 so lets do it with if statements.

if( ($value1 $value2) == $answer ){
     die(
"20 + 20 equals 40");

ok so we now understand the if the expression is true then it would od what you asked for within the braces {...} but what if it is false? well theres another keyword thats highly used and this is called "else".. here is an example.

PHP Code: 
$value1 20;
$value2 10;
$answer 40;

if( (
$value1 $value2) == $answer ){
     die(
"20 + 10 equals 40");
}else{
    die(
"20 + 10 does NOT equal 40"); 

END::

ok so now we have gone over a few of the basics if you like the tutorial ill carry on and create some more showing you how to uses mysql, foreach, and help you get further to learning php.

Thanks.
litewarez Reviewed by litewarez on . PHP tutorial Heya webmsaters.. ive seen a few of you the are oblivious to php so im going to starts a tutorial / guide for you all Ok so lets begin ______________________________________ Tutorial Info: Name: Simple Functions. Level: Basic. Rating: 5