PHP Questions

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

MMJ

Thread Starter
Guest
Joined
Oct 15, 2006
Messages
3,625
I have some php questions that I would appreciate if anybody can answer. :)

Whenever a word has a dollar sign in front of it that means it is a variable right? e.g. $test

. is like & (vb) or + (JS) right?

More to come... :)
 

MMJ

Thread Starter
Guest
Joined
Oct 15, 2006
Messages
3,625
There seems to be certain words that have a dollar sign if front of them that are not variables, e.g. $_POST

What is that?
 

DrP

Joined
Jul 23, 2005
Messages
739
$variable is a variable within the page being worked on.
$_POST['variable'] was passed to the page from a form using the method POST.
$_SESSION['variable'] was passed through the use of a session cookie.
$_GET['variable'] is passed through the url or from a form using the method GET.
If you have Global Variables turned on in your php.ini then all of the above would be accessible through $variable, I think. But if Global Variables is turned off then you need to refer to the variables correctly by type - as above. It's safer to Global Variables turned off btw.
There are others, too.
 
Joined
Apr 30, 2005
Messages
3,012
DrP said:
$variable is a variable within the page being worked on.
$_POST['variable'] was passed to the page from a form using the method POST.
$_SESSION['variable'] was passed through the use of a session cookie.
$_GET['variable'] is passed through the url or from a form using the method GET.
If you have Global Variables turned on in your php.ini then all of the above would be accessible through $variable, I think. But if Global Variables is turned off then you need to refer to the variables correctly by type - as above. It's safer to Global Variables turned off btw.
There are others, too.
And when you looked in your php.ini file (to avoid confusion) it's called "Register Globals" ;)

You can also find a list of various variables you can use by creating a php file with this in it:
<?php
phpinfo();
?>
and uploading it to your server.
 

MMJ

Thread Starter
Guest
Joined
Oct 15, 2006
Messages
3,625
brendandonhu said:
$_POST is a variable.
. is the string concatenation operator.
Does $_POST always have to be defined?
 
Joined
Apr 30, 2005
Messages
3,012
$_POST is a Superglobal, it "posts" the data received from a form that uses the method of post.

So if you had

<form method="post">
whatever
</form>

you could use $_POST to display the data you got from the form on a page.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top