what is this "$" sign in echo $row ?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

User avatar
gether
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Dec 25, 2012 7:38 pm

what is this "$" sign in echo $row ?

Postby gether » Wed Jan 30, 2013 1:51 am

what is it called in php ?

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: what is this "$" sign in echo $row ?

Postby simplypixie » Wed Jan 30, 2013 4:29 am

Dollar Sign - it doesn't have a special name.

However, if you mean what does it represent in PHP then it is always required to indicate a variable.

User avatar
gether
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Dec 25, 2012 7:38 pm

Re: what is this "$" sign in echo $row ?

Postby gether » Wed Jan 30, 2013 5:42 am

you mean a variable name of our choice comes after the "$" sign ?

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: what is this "$" sign in echo $row ?

Postby simplypixie » Wed Jan 30, 2013 5:52 am

Yes

User avatar
gether
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Dec 25, 2012 7:38 pm

Re: what is this "$" sign in echo $row ?

Postby gether » Wed Jan 30, 2013 6:02 am

but the variable name row is something that we cannot assign as a variable name ?

because it is a special variable name ...?

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: what is this "$" sign in echo $row ?

Postby simplypixie » Wed Jan 30, 2013 6:07 am

No it is not a special name, it is just used a lot when looping through arrays, for example

Code: Select all

while ($row = mysql_fetch_array($result)) {
echo $row['id'];
}


However you could also use any name you like

Code: Select all

while ($sausage = mysql_fetch_array($result)) {
echo $sausage['id'];
}

User avatar
gether
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Dec 25, 2012 7:38 pm

Re: what is this "$" sign in echo $row ?

Postby gether » Wed Jan 30, 2013 6:18 am

since i am learning html php and mysql

few things keeps coming in different forms...



$row
$_GET

variable name
variable value

labelname
labelvalue

feildname
feildvalue

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: what is this "$" sign in echo $row ?

Postby simplypixie » Wed Jan 30, 2013 6:24 am

Sorry I don't know what your question is. However, I would learn HTML first and then move to PHP they are 2 very different coding languages and you may just confuse yourself trying to learn both at the same time.

User avatar
gether
New php-forum User
New php-forum User
Posts: 16
Joined: Tue Dec 25, 2012 7:38 pm

Re: what is this "$" sign in echo $row ?

Postby gether » Thu Jan 31, 2013 1:48 pm

yea i just get confused with some of the php reserved words ...

with variable names that we assign for some purpose ..

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: what is this "$" sign in echo $row ?

Postby seandisanti » Thu Feb 07, 2013 12:57 pm

the dollar sign designator bypasses a lot of the issues you have in other languages with reserved words. The only place where you could really screw something up by using a reserved word would be with function and class names, since the identifiers are not prefixed with the dollar sign. The number of words you could cause issues with is fairly limited though and pretty common sense. If you're trying to declare new function if() for example, it won't work as intended and you'll get fatal errors.


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests