Visual Communications Home

Vcom 62/162 :: Adv Web

PHP Group

I’m going to start using this page to post information, code, and homework for those that are part of my php group that meets regularly on Wednesdays after class. BasicPHP-Tutorial

Conditions example: if, else, else if

$d=date("D");

if ($d=="Fri"){
echo "Have a nice weekend!";
}
elseif ($d=="Sun"){
echo "Have a nice Sunday!";
}
else {
echo "Have a nice day!";
}

Functions example


function functionName()
 {
 code to be executed;
 }

Using a function


function writeName()
 {
 echo "Kai Jim Refsnes";
 }

 echo "My name is ";
 writeName();

And the output will be


My name is Kai Jim Refsnes

Homework

Last time you were asked to create a php file that uses both: an if, else, else if conditions; and a simple php function that you define, and then declare. Please make sure that you create a link to php work on your homework pages. It was not mentioned last time, but please also save a .txt version of your file so that I can view your php code without having to download your file.

Resources

w3schools.com php.net manual - Operators, strings, string functions reference tizag.com/phpT/