Jump to content

include


user4fun

Recommended Posts

what is the difference betweeninclude 'info_send.php';andinclude ("info_send.php");andinclude "info_send.php";the reason why i ask is that because none of them work for me?lolwhy am i using this1. form, user inputs emailscript, validates email, the right chracters and allif correctecho "good";include yada yada yada ( a file that send email sayig thank you"elsedie

Link to comment
Share on other sites

According to me there is no difference!

Link to comment
Share on other sites

There's no difference. But this looks better:

include( 'somfile.php' );

There's a difference between ' and ". if you use double-quots you can include varibales dirrectly in the string and you can use espaces (\n \t etc), if you use single-quots you can't do that and you can only escape other single-quots.

$Hello = 'Hey';echo '$Hello, who\tare you? I\'m called joe'; // I'm not...echo "\n"; // Added a newline...echo "$Hello, who\tare you? I'm called joe"; // I'm not...echo "\n"; // Added a newline...---This will echo:$Hello, who\tare you? I'm called joeHey, who	   are you? I'm called joe

When it comes to the rest, I didn't follow you completely, so I can't help you with that at the moment..Hoep that helped...Good Luck and Don't Panic!

Link to comment
Share on other sites

the reason why i ask is that because none of them work for me?
Is that a question? If include statements "don't work" for you, then you probably need to uninstall PHP and reinstall it. There's nothing wrong with the include syntax you wrote. So if it just "doesn't work", then you probably need to reinstall. But I would guess that there is something else in your code causing problems, and that includes are working just fine. Error messages might be disabled, so you might not even know about an error. But, you said they don't work, so I'll take your word for it and just tell you to reinstall PHP. I've never seen an include statement just "not work", so that would indicate a serious problem with your PHP installation.
Link to comment
Share on other sites

Maybe you are including a file that does not exist or you are writing the wrong URL for the file

Link to comment
Share on other sites

include ("info_send.php");

Make certain that this file (info_send.php) is in the same folder as the script which calls it or add a referencing value to find the correct folder.ie: if the include is in the folder above the script, use include include ("../info_send.php");

Link to comment
Share on other sites

I've seen some strange behavior with include paths. For example, assume you have a file structure where you have your base PHP script, maybe called test.php, in a given folder, say called test. So you have /test/test.php. Assume there are two include files in a folder called includes, so you have /test/includes/inc1.php and /test/includes/inc2.php. Now you have test.php including inc1.php like this:include("includes/inc1.php");Simple enough. The strangeness comes when inc1.php tries to include inc2.php. It can use either the path from the source script (test.php) to the include file, or the path from the one include to the other, and both of them work and include the same file. For example, inc1.php looks like this:

<?phpecho "inc1.php";include "inc2.php";include "includes/inc2.php";?>

Both of those include statements will include the same file. That might cause a problem if you have /test/includes/includes/inc2.php, then the include would be ambiguous.I'm not sure what the moral of the story is, just something to be aware of.

Link to comment
Share on other sites

You should check the configuration directories. There is a setting that allows you to tell PHP where to look for the files. You can read about it here:http://us3.php.net/manual/en/ini.core.php#ini.include-pathAlso:To the best of my knowledge there is no difference between using include("") and include "". The only difference is between include and require. Require() and include() are identical in every way except how they handle failure. They both produce a warning, but require() results in a Fatal Error. In other words, don't hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless.

Link to comment
Share on other sites

Just to point out, the parentheses are not required for include, require, or echo, but are there for clarification. There is no difference between these two:include "file.php";include ("file.php");But there is significant difference between these:

<?phpecho include "file" . ".php";echo include ("file") . ".php";echo include ("file" . ".php");echo (include "file" . ".php");echo (include "file") . ".php";echo (include ("file") . ".php");echo (include ("file" . ".php"));?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...