raa Posted June 21, 2007 Share Posted June 21, 2007 Most of my "scripting" experience is with pawn(I believe that is the correct name). http://www.amxmodx.org/doc/source/scripting/intro.htm I've made a few things with php and am still learning when I have time. I've noticed php is a little different then what I'm used in that the below code <? $name = "yourname"; echo $name; ?> just blurps out and runs when you load it. however, with what I'm used to you would have to make a function like, public displayname(id) { new name[32] name[id] = "yourname" client_print(id,print_chat,"Your name is %s ", name) } that would print "yourname" (if i setup a command for you to type) when you typed the command. I see the uses of having the code in php just get ran through when the page is loaded. However, I need to have some power over what is ran and when. I did a little reading, but I'm not sure what the terminology is, so searching isn't turning up much. I've looked into using PHP functions like function func1() { // DO STUFF } but I didn't like how the passing of variables was working out. seemed crazy having to put every single variable used in the .php within the function "()" in-order for the function to work. anyway I know you guys are way advanced and get a lot of noobs wandering in here asking stupid questions like I have, but If I could please get a little direction and advice. Links and such help I guess and I'll take w/e you have time to offer, but what I'm really needing atm is some human direction. thanks for reading... Quote Link to comment https://forums.phpfreaks.com/topic/56515-newb-confusion/ Share on other sites More sharing options...
genericnumber1 Posted June 21, 2007 Share Posted June 21, 2007 variables in php are preceded with $ <?php function test($variable) { echo $variable; } test('muffin'); ?> an introduction to php programming... http://www.hudzilla.org/php/ Quote Link to comment https://forums.phpfreaks.com/topic/56515-newb-confusion/#findComment-279110 Share on other sites More sharing options...
redarrow Posted June 21, 2007 Share Posted June 21, 2007 you need to learn class then. http://www.hudzilla.org/php/6_0_0.php Quote Link to comment https://forums.phpfreaks.com/topic/56515-newb-confusion/#findComment-279111 Share on other sites More sharing options...
genericnumber1 Posted June 21, 2007 Share Posted June 21, 2007 you need to learn class then. http://www.hudzilla.org/php/6_0_0.php Don't throw him at the world of OOP yet . Go in order, oop should IMO be learned after procedural for PHP and then he can decide which he likes. Quote Link to comment https://forums.phpfreaks.com/topic/56515-newb-confusion/#findComment-279123 Share on other sites More sharing options...
chronister Posted June 21, 2007 Share Posted June 21, 2007 Functions are about the best way to control what gets ran and when. If you don't want to pass vars in the function itself, then you can call those vars as global. <?php $x=1; $y=2; $z=5; function addem() { global $x,$y,$z,$total; $total=$x+$y+$z; } addem(); echo $total; ?> Returns 8 Hope it helps a bit Quote Link to comment https://forums.phpfreaks.com/topic/56515-newb-confusion/#findComment-279141 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.