Jump to content

define/$var


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 post
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 post
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 post
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 post
Share on other sites

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...