Support Forums

Full Version: PHP Tut 2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
<snip> But i found it hard to understand.
I have had people say it is easy, you're the first to say it's hard.

Although, I apologize for you having trouble.