
~Thanks
~Messi
Thank you alexrules01 helped alotalexrules01 wrote:Well variables are basically a placeholder to store a number or characters/strings.
Think of a basic maths question, a + b = c where a = 1 and b = 2
a and b are variables, and is a variable of the sum of a and b ( c = 3)
Start to play with variables in PHP. The code to set the a and b variables, add them together and print out c would look like this
REMEMBER: All variables start with a dollar sign ($). This tells the computer that you are using a variable
<?php
$a = 1;
$b = 2;
$c = $a + $b;
print $c;
?>
Code: Select all
<?php
$str = '1000';
$rank = '1';
$wealth = '1,000,000,000';
print 'Str = <b>$str<b/>
<br />
Rank = <b>$rank<b/>
<br />
Wealth = <b>$wealth<b/>'
?>
Code: Select all
Str = $str
Rank = $rank
Wealth = $wealth
It is all there. The Fallen Empire game you linked was not particularly complex. If you are having a hard time determining how to code your game, you should pick up a regular PHP book and learn some of the academic side of programming. This is one of the best PHP and MySQL books out there. I understand that you want to start making your game now, but if you don't have the programming ability to complete it, you will actually save time by spending 5 or 6 months learning the ins and outs of PHP, versus spending a year stumbling through it and not having a solid, scalable game to show for it. Halls' tutorials are a huge help, but if you are wanting to make something radically different, you really need a strong grounding in programming.Messi wrote:But how can i make the game that i want out of this?
just to be more detailed about it, heres the link to the sort of game i want to make; http://www.age2.fallofempires.com
i really want to get making the game as ive been looking for about 4 and a half months now
There is a subtle difference between single-quotes and double-quotes. The text inside double-quotes is evaluated for variables. To help illustrate this, here is an example:Messi wrote:EDIT:
And one more question:
What is wrong with this code?it just shows like this in wampserver;Code: Select all
<?php $str = '1000'; $rank = '1'; $wealth = '1,000,000,000'; print 'Str = <b>$str<b/> <br /> Rank = <b>$rank<b/> <br /> Wealth = <b>$wealth<b/>' ?>
Code: Select all
Str = $str Rank = $rank Wealth = $wealth
Code: Select all
$strength = 15;
echo "His strength is $strength!"; //prints "His strength is 15!"
echo 'His strength is $strength!'; //prints "His strength is $strength!"