Jump to content

define/$var


PrateekSaxena

Recommended Posts

Hi,I am a complete n00b at PHP.Please tell me the difference between.define(NAME, 'prateek');and $name ='prateek'.Also I am not able to include('some.php?q=t');why is that?

Link to comment
Share on other sites

For the first one - the former statement defines a constant, which does not change all through script execution, while the latter defines a variable which can be changed.For your second question, you cannot pass querystrings through include() statements, instead just define a variable and read it from the included script

$q = t;include("some.php");

Link to comment
Share on other sites

For your second question, you cannot pass querystrings through include() statements
To add to that, $_GET inside an included file refers to the same variables as $_GET outside the file, it's the same array. Using $_GET inside an included files doesn't include any variables in the include statement, only variables in the URL of the page itself.
Link to comment
Share on other sites

Think of the include() function as simply copying and pasting the code from the included file into your main script.

Link to comment
Share on other sites

Sorry for such a delayed reply.is include like require() in ruby?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...