register_global, endif, urlencode

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
Haku
Forum Newbie
Posts: 3
Joined: Thu Aug 19, 2004 4:28 pm
Location: Canada

register_global, endif, urlencode

Post 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-
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: register_global, endif, urlencode

Post 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.
Haku
Forum Newbie
Posts: 3
Joined: Thu Aug 19, 2004 4:28 pm
Location: Canada

Thanks

Post by Haku »

Thank you feyd,

I understood now :o

-Haku-
Post Reply