Page 1 of 1

Newbie question, simple variables

Posted: Sat Feb 05, 2011 11:43 am
by stevebeans
Hi there, sorry for what is likely a newbie question. The answer is likely as easy as what you'd think, but I don't know a lick of PHP. I hacked around in .asp for awhile, but got a linux box and still learning the ropes.

My question is, I was just wondering how you declare a variable then call it wherever you want on your page.

If this is PHP 101, feel free to point me in a good direction where to also learn the basics of stuff like this :)

Thank you!!

Re: Newbie question, simple variables

Posted: Sat Feb 05, 2011 11:59 am
by social_experiment

Code: Select all

<?php
 // declare the variable
 $variable = 10;

 // echo to the browser, will print 10
 echo $variable;
?>
You should look at the php manual and w3schools. Both these have information about variables, declaring, naming guides etc.
Hth

Re: Newbie question, simple variables

Posted: Sat Feb 05, 2011 1:14 pm
by stevebeans
Thank you, I'm definitely going to take a look at that

Re: Newbie question, simple variables

Posted: Sat Feb 05, 2011 5:30 pm
by mellowman
if your having problems with beginner things like variables try to read some tutorials...

Here are some examples -> http://w3schools.com/php/default.asp

Re: Newbie question, simple variables

Posted: Sat Feb 05, 2011 5:34 pm
by stevebeans
Yea, I forgot about w3schools, I'm definitely going to check that out and hopefully get brushed up on basic php. I'll come back and bug you guys for more advanced stuff :)