Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP Tut 2
#1
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
Reply
#2
<snip> But i found it hard to understand.
Reply
#3
I have had people say it is easy, you're the first to say it's hard.

Although, I apologize for you having trouble.
[Image: iAHg.png]
I sound like Morgan Freeman
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 943 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,674 10-10-2011, 01:00 PM
Last Post: Greyersting
  [TUT] PHP Shell Scripting Gaijin 8 8,389 08-05-2011, 09:34 PM
Last Post: BreShiE
  [TUT] PHP Password Protected Page PurpleHaze 23 6,997 05-20-2011, 02:56 AM
Last Post: stephen5565
  [TUT] Pagination using PHP Gaijin 7 4,977 11-01-2010, 09:01 AM
Last Post: Arеs

Forum Jump:


Users browsing this thread: 1 Guest(s)