Re: Syntax Error -> This is WEIRD!

From: Date: Fri, 16 Jan 2004 17:50:05 +0000
Subject: Re: Syntax Error -> This is WEIRD!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-174853@lists.php.net to get a copy of this message
Donald Tyler wrote:
Yes your right, that’s exactly the problem. I didn’t even realize he was doing that. By including the PHP file via HTTP, you are including the OUTPUT of the PHP file, not the actual PHP file itself. e.g. by including a file with the following code: <?PHP print 'Hello'; ?> you would be including the word "Hello" as PHP code, which is obviously going to cause a syntax error. Yes. I read the manual which provides no clear explanation (I suspect that whoever wrote it didn't actually know how it works). So I decided to test it. It does exactly what you say it does. I made an include file like this:
<?php echo '<?php echo "Hello World!"; ?>'; ?> If you inlude that using HTTP, it outputs "Hello world!" Seems like a strange thing to do, outputting PHP code on a Web page, but it's not without conceivable usefulness.
-----Original Message----- From: Dagfinn Reiersøl [mailto:reiersol@online.no] Sent: Friday, January 16, 2004 10:18 AM To: PHP General Subject: Re: [PHP] Syntax Error -> This is WEIRD! Nick Wilson wrote:
if a script calls antohter like 'include('http://site.com/index.php'); Why would I get a syntax error on line 1 of index.php when it looks like this: <?php // line one above this one What's the deal there? Many thanks for any insight ;-)
I've never tried to do an include via HTTP, so maybe I'm clueless, but it occurs to me that it might be a good idea to try doing a plain old file include, using exactly the same file. I have the feeling it would be interesting to know whether that would work or not.


« previous php.general (#174853) next »