Page 1 of 1

PHP CODING

Posted: Wed Aug 18, 2010 3:36 pm
by Messi
Where do i learn how to code in php? Its really hard and i've done the Browser MMO tut. Where do all you guys learn how to code in PHP ? Ive looked at http://www.w3schools.com/php/default.asp but i couldn't learn anything :(

~Thanks
~Messi

Re: PHP CODING

Posted: Wed Aug 18, 2010 4:06 pm
by Asgarth
Hello m8.

Start here to get a general understanding of what php is and what it can do.
http://en.wikipedia.org/wiki/PHP

Then when you have read trough all this, you can doo a http://google.com search for how to code in php or php beginner tutorials.

Basicly all of us here, well most of us have been coding in php for a while, and we started just where you are about to start.

So first take a look at what php is and what it can do for you.

Once you have done this, you can start making some basic apps such as hello world :
<?php
echo "Hello World";
?>

Have fun learning.

Re: PHP CODING

Posted: Wed Aug 18, 2010 7:06 pm
by hallsofvallhalla
the tuts help out a bunch. Once you understand what i am doing there you can build from it. So find out what kind of game you want to make and start it. If you are stumped on what to do look up how to do that certain thing. Dont try to just read about all of PHP. It will be boring.

Re: PHP CODING

Posted: Wed Aug 18, 2010 7:41 pm
by rockinliam
Hall's tutorials of course, watch and absorb my friend, head on over there learn the basics and go build what you wanna build!
Now go! http://indie-resource.com/forums/viewforum.php?f=33

Re: PHP CODING

Posted: Thu Aug 19, 2010 4:17 am
by Callan S.
Are you asking how to code like the browser games that have had $$$ or $$$$ spent on their design and layout? How to code that awesomely? Well, you spend $$$ or $$$$.

Asgarth is right with his hello world example. All games, no matter how awesome, are comprised of very simple elements. Alot of them. Start making simple elements and building on them.

Sometimes it seems to small to write something like a hello world program, but if you post about it I'll write an encouraging reply on it. The small stuff does deserve congrats as much as the big stuff.

Just remember not to compare yourself to some flashy web games out there - it's not fair on yourself. It'd be like comparing yourself to a world class violinist the first time you pick up a violin.

Good luck!

Re: PHP CODING

Posted: Sat Aug 21, 2010 12:44 pm
by Messi
Sorry for the late reply...

Thanks everyone i appreciate the replies;

im looking to make a turn-based game with rounds.

e.g
Like when a certain team has won, the whole game resets again etc.

the thing with php that makes me confused and i stuggle is with variables and things like that :S
so i need a decent site to learn where you guys did and i will certainly use google first :)

Re: PHP CODING

Posted: Sat Aug 21, 2010 3:11 pm
by alexrules01
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;
?>

Re: PHP CODING

Posted: Sat Aug 21, 2010 3:34 pm
by Messi
alexrules01 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;
?>
Thank you alexrules01 helped alot :) i will play around now with it

Re: PHP CODING

Posted: Sun Aug 22, 2010 7:08 am
by Messi
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 :roll:


EDIT:

And one more question:

What is wrong with this code?

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/>'
	   
?>
it just shows like this in wampserver;

Code: Select all

Str = $str
Rank = $rank
Wealth = $wealth

Re: PHP CODING

Posted: Sun Aug 22, 2010 7:53 am
by Jackolantern
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 :roll:
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:EDIT:

And one more question:

What is wrong with this code?

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/>'
	   
?>
it just shows like this in wampserver;

Code: Select all

Str = $str
Rank = $rank
Wealth = $wealth
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:

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!"
So if you want to actually get the value inside a variable in an echo or print statement, you need to use double-quotes. Also, you should use "echo" instead of "print". They are almost the same, but again, there is a subtle difference: echo returns no value, whereas print does, meaning it performs slightly more slowly.