Page 1 of 1

Problem on include

Posted: Sun Feb 07, 2010 11:19 am
by tgckpg
b.php
<?php
$root = 'C:\';
?>

a.php
<?
include 'b.php';
echo $root;
?>

on commandline:
C:\cmdUtilities>php a.php
PHP Warning: Directive 'register_globals' is no longer supported in PHP 6 and g
reater in Unknown on line 0
PHP Warning: Directive 'register_long_arrays' is no longer supported in PHP 6 a
nd greater in Unknown on line 0
PHP Warning: Directive 'magic_quotes_gpc' is no longer supported in PHP 6 and g
reater in Unknown on line 0

Parse error: syntax error, unexpected $end in C:\cmdUtilities\b.php on line 2

Why I'm getting this error?

Re: Problem on include

Posted: Sun Feb 07, 2010 5:13 pm
by klevis miho
are a.php and b.php in the same folder?
I would use include('b.php'); rather than include 'b.php';

Re: Problem on include

Posted: Mon Feb 08, 2010 11:38 am
by tgckpg
thanks for replying!
I'm really hoping helps for this.(worrying if no one answered)

Yes,they are in the same folder.
As you see, then error shown "in b.php"
and I'm running a.php (ie,php checks b.php through a.php)

I'd tried "include" with brackets, without brackets, " and ' .
but it still reporting the error.

Why?

Re: Problem on include

Posted: Mon Feb 08, 2010 12:12 pm
by klevis miho
Paste all the code here

Re: Problem on include

Posted: Mon Feb 08, 2010 12:47 pm
by AbraCadaver

Code: Select all

$root = 'C:\\';

Re: Problem on include

Posted: Tue Feb 09, 2010 12:05 pm
by tgckpg
AbraCadaver wrote:

Code: Select all

$root = 'C:\\';
Oh, thanks!This works!
But I feel dumb for such "changes"...

Re: Problem on include

Posted: Tue Feb 09, 2010 12:28 pm
by AbraCadaver
tgckpg wrote:
AbraCadaver wrote:

Code: Select all

$root = 'C:\\';
Oh, thanks!This works!
But I feel dumb for such "changes"...
That line was generating a parse error, because the \ was escaping the ' and so there was no closing '

Use this when developing:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', '1');
Or set these in php.ini on the development machine.