Page 1 of 1

register_global, endif, urlencode

Posted: Thu Aug 19, 2004 4:28 pm
by Haku
Hi everybody,
I am new to this forum and also PHP :)

I need help concerning register_global, endif and urlencode

Register_global:
When register_global is turned off, we need to use the $_GET['...'] function to retrieve value sent from another page right ?

In my case, I am sure that the register_global is already turned off, however, in retrieving value passed from another page, I simply use $varName and it works. Why ?

endif:

Is the use of endif needed everytime I use if statement ?
In my case, when I use endif, the page is not working. So I just remove the endif, and everything works fine.
Here is part of the code:
if (!$dbCon)
die ("DIE");
else{
echo "Live";
mysql_select_db('TSProject', $dbCon);
$test = "Yey";
}
endif; // using endif will make the code not working

urlencode:
What does this function actually do ?

Thank you very much,

-Haku-

Re: register_global, endif, urlencode

Posted: Thu Aug 19, 2004 4:43 pm
by feyd
Haku wrote:Hi everybody,
I am new to this forum and also PHP :)
Welcome!
Register_global:
When register_global is turned off, we need to use the $_GET['...'] function to retrieve value sent from another page right ?
When register_globals is off, $_GET, $_POST, $_COOKIE, $_SESSION should be used to access the data passed to the page.
In my case, I am sure that the register_global is already turned off, however, in retrieving value passed from another page, I simply use $varName and it works. Why ?
The data shouldn't be available through the $varName immediately, unless, a prepended script, or one of your includes is extracting them.. The extraction can be done through a variety of means. I'm unsure how it would happen if none of these conditions are true..
endif:

Is the use of endif needed everytime I use if statement ?
In my case, when I use endif, the page is not working. So I just remove the endif, and everything works fine.
Here is part of the code:
if (!$dbCon)
die ("DIE");
else{
echo "Live";
mysql_select_db('TSProject', $dbCon);
$test = "Yey";
}
endif; // using endif will make the code not working
endif is only required when you use the alternate form of if's.. often people use braces ( { and } ) to enclose the code they wish to run. The braces aren't required if the code to run is only 1 line long, however. The alternate ifs look like:

Code: Select all

<?php

if( expression ):
  statement 1;
  ...
  statement n;
endif;

?>
urlencode:
What does this function actually do ?
urlencode translates a string into a form that can be used in urls.

Thanks

Posted: Thu Aug 19, 2004 4:53 pm
by Haku
Thank you feyd,

I understood now :o

-Haku-