PHP variable defining syntax help

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
Basit
Forum Newbie
Posts: 5
Joined: Thu Jul 23, 2009 1:14 am

PHP variable defining syntax help

Post by Basit »

Hi to all 8) ,
hope every one is fine.Can any one tell me when we declare variable like this

var $ob_Status = "<pre>";

$ob_Status is a variable but what is var and did "<pre>" has a special meaning in PHP or its just a constant here

Also what is mean by underscore when we define variable like this

$Host_ , $Out_ , $Line_
and

$_Server, $_Port , $_State

please explain this statement that what its mean,how its work

var $ob_Data = array(array ( null, "HELO : \$_Host", 250) // 0
,array ( 4, "AUTH LOGIN", 334) // 1
,array ( null, "\$_Login", 334) // 2


Thanks in advance :wink:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP variable defining syntax help

Post by VladSun »

Basit wrote:Can any one tell me when we declare variable like this

var $ob_Status = "<pre>";

$ob_Status is a variable but what is var and did "<pre>" has a special meaning in PHP or its just a constant here
You can use this form of "variable declaration" only in a class definition. Otherwise, simply skip the "var" part like this:

Code: Select all

$newVariable = 5;
Basit wrote: Also what is mean by underscore when we define variable like this

$Host_ , $Out_ , $Line_
It's not PHP specific, but developer's style specific. Feel free to choose your own naming convention, though there are some "best pratice" ones.
E.g.:
http://framework.zend.com/manual/en/cod ... style.html
Basit wrote:$_Server, $_Port , $_State
Probably you meant "$_SERVER", etc. Take a look at this:
http://us2.php.net/manual/en/reserved.variables.php
There are 10 types of people in this world, those who understand binary and those who don't
Basit
Forum Newbie
Posts: 5
Joined: Thu Jul 23, 2009 1:14 am

Re: PHP variable defining syntax help

Post by Basit »

Hi,
Thanks for the reply.You mean defining _ in the end like $Out_ is only a matter of style only and is same as $Out and Pre _ like $_Server means already defined variables.
Thanks :)
Post Reply