Support Forums
PHP Tut 2 - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: PHP Tut 2 (/showthread.php?tid=8062)



PHP Tut 2 - Minus-Zero - 06-29-2010

Ok its Minus again with php tut 2! Today will be learning all about variable!

Lets begin!

Code:
<html>
<head></head>
<body>

Hmm...Whats your favorite Site and what is your favorite thing about it?
<br />

<?php
//define your variables(remember this is a comment)!!!
$site = 'Exploitnation.org';
$aka = 'ExN';
$rsn = 'Community';

echo "Well its URL is $site . But people just call it $aka ! My favorite thing is the $rsn ...... "

?>

</body>
</html>

Now to explain!

$site = 'Exploitnation.org';

$site
This is basically what you write to call for the variable... or whatever you would say! So its what i wrote
in echo so that it would print Exploitnation.org

'Exploitnation.org';
This is what will print or be used when you call for the variable.... So basically it what the processor
converts the $site into!

Well nothing more to explain on that! Now lets move onto other ways to write variables!

Code:
<?php
$num1 = '100';
$answer = $num1 + 10;

echo " Hey what is 100+10? It is $answer ";

?>

Ok well here you can see i used a variable to define another variable! Omg im not jesus calm down thats just PHP at work...

All you have to do is define a variable, then you can use that define variable to define another!

Lets move onto this... it l assigns three variables the same value simultaneously! Now i know you think im jesus!

Code:
<?php
$side1 = $side2 = $side3 = 100;

echo " Hey what are the lengths of this triangle? Umm are they $side1 $side2 and $side3 ? ";

?>

As you can see it defined $side1 $side2 and $side3 as 100!!!!!

Which means you can have variables all equal the same thing!

Ok well thats all for now! Hope it helped


RE: PHP Tut 2 - groovybluedog - 07-04-2010

<snip> But i found it hard to understand.


RE: PHP Tut 2 - Minus-Zero - 07-04-2010

I have had people say it is easy, you're the first to say it's hard.

Although, I apologize for you having trouble.