I am trying to include a php document which name is news.php, but because I am doing this on a local server files navigate trough \ and not /
My code looks as follows:
<?php include("\xnews
ews.php");?>
But because of the which in php means newline (I believe) the output views the error:
Warning: include(\xnews\ews.php): failed to open stream: No such file or directory in C:\Users\Johanne-PC\Desktop\EasyPHP-12.0\www\my portable files\Homepage
ews.php on line 44
Is there any way I can bypass this and include it successfully?
Use \:
<?php include("\\xnews\
ews.php");
You can also use single quotes (which don't escape):
<?php include('\xnews
ews.php');
Additionally, you can (edit: on all systems), use /:
<?php include('/xnews/news.php');
<?php include("\\xnews\
ews.php");?>
The problem is that \
is what's known as the escape character - it's used in special circumstances, such as being a newline. So to get an actual
\
character, you have to escape it with a second \
. As the other answers have said, you need to use:
<?php include("\\xnews\
ews.php");?>