HTML in PHP
[edit]
2 Minutes after I posted this i figured it out
However, I came up with a new question!
What's the difference between global(), include() and require()
Thanks
[edit]
2 Minutes after I posted this i figured it out
However, I came up with a new question!
What's the difference between global(), include() and require()
Thanks
Mark Hensler posted this at 22:42 — 13th April 2002.
He has: 4,048 posts
Joined: Aug 2000
Is this the global you mean?
http://www.php.net/manual/en/language.variables.scope.php
include vs require, the short version:
include()
include inserts the source code for a file when the include() call is read. If the file cannot be included, an error will be printed an error will be printed and the script will continue. If the include() statement is within IF statements, the file will only be included if the IF statement evaluates to true.
require()
require() inserts the source code for the file prior to processing. If the file cannot be inserted, the script will not continue. If the require() call is within IF statements, the file will be required regardless of wether the IF statment evaluates to TRUE or not.
Mark Hensler
If there is no answer on Google, then there is no question.
theprofessional posted this at 12:29 — 16th April 2002.
They have: 157 posts
Joined: Mar 2002
Global is an easy one.
Just use include() always unless you absolutely need to require() a file somewhere no matter what.
Abhishek Reddy posted this at 14:00 — 16th April 2002.
He has: 3,348 posts
Joined: Jul 2001
Because require() inserts the contents of a file before processing, it comes in handy when you need to include stuff like common variables needed for a script in that page. Thats the most common use I have for it.
Otherwise, as theprofessional says, use include().
Wil posted this at 14:16 — 16th April 2002.
They have: 601 posts
Joined: Nov 2001
Are these similar to 'use' and 'require' in Perl? In Perl, require is pulled in when needed, where an use block is evaluated at compile time?
Mark Hensler posted this at 20:00 — 16th April 2002.
He has: 4,048 posts
Joined: Aug 2000
sounds like it
Mark Hensler posted this at 20:03 — 16th April 2002.
He has: 4,048 posts
Joined: Aug 2000
also... global isn't really a function, it's a declaration that defines the variables scope.
Wil posted this at 08:41 — 17th April 2002.
They have: 601 posts
Joined: Nov 2001
Yeah, I gathered that. Similar to when using 'use strict' in Perl, you have to define global, local variables etc.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.