Extremely new to php. Just started learning 3 days go im trying to print a random number from one to ten. would this work? or should i use echo? or am i totally in left field here. thanks. would it be pure random? like a 1 in 10 chance for each number to show? <? $Number=rand(1,10) print("$Number"); ?> Code (markup): Edit: wrong opening tag
If you want to get in to programming, get familiar with and used to looking at programmer's documentation. In this case, http://www.php.net/manual/en/
yeah, sorry i knew that. ill edit and change it. and for the first poster thanks for that link as well. im reading a how to book by sams. for mysql apache and php. so i guess with the change it will work thanks
int rand ( [int $min, int $max] ) If called without the optional min, max arguments rand() returns a pseudo-random integer between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use rand (5, 15). In general, rand is good enough. Pseudo-random PHP functions and truly random number generators - see http://www.phpfive.net/article2.htm. In your example, you'd need: $Number=rand(1,10) print("$Number"); Code (markup):
I'm not going to talk about what is good or not on how to implement this. This is just a simple random number from 1 to 10. Strictly speaking, this will not work just in case you were testing it: $Number=rand(1,10) print("$Number"); PHP: Simply because you have no semicolon at the end of the first line. This should work. $Number=rand(1,10); print("$Number"); PHP:
ahh ok, good eyes then... I am a all lower caps guy, so camel caps annoys me because I can never pick it up