Newbie question, simple variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stevebeans
Forum Newbie
Posts: 6
Joined: Sat Feb 05, 2011 11:38 am

Newbie question, simple variables

Post 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!!
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Newbie question, simple variables

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
stevebeans
Forum Newbie
Posts: 6
Joined: Sat Feb 05, 2011 11:38 am

Re: Newbie question, simple variables

Post by stevebeans »

Thank you, I'm definitely going to take a look at that
mellowman
Forum Commoner
Posts: 62
Joined: Sat Nov 22, 2008 5:37 pm

Re: Newbie question, simple variables

Post 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
stevebeans
Forum Newbie
Posts: 6
Joined: Sat Feb 05, 2011 11:38 am

Re: Newbie question, simple variables

Post 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 :)
Post Reply