| | |
common webpage content
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
As a beginner, I suggest you use the function "require" like this:
Yes, require has a different syntax, to avoid future problems, always surround the hole statement with parenthesis.
php Syntax (Toggle Plain Text)
(require "includes/common.php");
Last edited by kadimi; Mar 17th, 2009 at 4:38 pm.
Need tech support? Ask Nabil
•
•
•
•
As a beginner, I suggest you use the function "require" like this:
Yes, require has a different syntax, to avoid future problems, always surround the hole statement with parenthesis.php Syntax (Toggle Plain Text)
(require "includes/common.php");
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
This works fine:
Whereas this produces a fatal error:
the error: Failed opening required '1' ... huh
-----------------------
From the PHP manual for include() (same rules apply for require):
Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value.
http://www.php.net/manual/en/function.include.php
php Syntax (Toggle Plain Text)
if( (require "sql.php") && 1) echo "success";
Whereas this produces a fatal error:
php Syntax (Toggle Plain Text)
if( require("sql.php") && 1) echo "success";
•
•
•
•
Fatal error: require() [function.require]: Failed opening required '1' (include_path='.;C:\php5\pear') in D:\wamp\www\test\index.php on line 2
-----------------------
From the PHP manual for include() (same rules apply for require):
Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value.
http://www.php.net/manual/en/function.include.php
Need tech support? Ask Nabil
I haven't seen anyone using require or include inside a brace like this though.
But the point to be noted is, include and require do return a value on successful inclusion. That return value is OK . Strange. I didn't know that
I wonder what would be the return value on failure.
Also, include and require are not functions. They are language constructs. Hmm! Not bad to learn few new things @ 2-30 am ? Eh ?
php Syntax (Toggle Plain Text)
<?php (include "db.php"); (require "db.php"); ?>
I wonder what would be the return value on failure. Also, include and require are not functions. They are language constructs. Hmm! Not bad to learn few new things @ 2-30 am ? Eh ?
Last edited by nav33n; Mar 17th, 2009 at 6:05 pm.
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
Other Threads in the PHP Forum
- Previous Thread: tomcat configuration
- Next Thread: Pointing to subdomain to main domain
Views: 355 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax alexa apache api array beginner beneath binary broadband broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion redirect regex remote script search select server sessions sms smtp soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






