Re: [PHP] Parse errors

2012-03-19 Thread tamouse mailing lists
On Sun, Mar 18, 2012 at 2:18 PM, Tim Streater t...@clothears.org.uk wrote:
 On 18 Mar 2012 at 17:46, Simon J Welsh si...@welsh.co.nz wrote:

 This is expected. The error doesn't occur to the second file is included, so
 everything in the first included file is parsed and run before execution is
 halted.

 Simon,

 Thanks for that. Looks like I should be able to catch most places where an 
 error might occur.

I tend to do a syntax check with php -l on the command line after
editing to see whatever errors might occur before I run the code on
the web site.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Parse errors

2012-03-18 Thread Tim Streater
After recently omitting a semicolon from the end of a statement, and having the 
result be a JavaScript error in an odd place, I'm trying to pin down just what 
PHP does with such errors. I made a small test script to run at CLI, which does 
some echoes and then, after that, I miss out a semicolon. On the command line, 
all I get is the parse error message with line number.

The script where I'd left the semicolon out of my production code is reached 
via AJAX, and sends some results back. It consists of a number of functions, 
then the main code appears, starting with two requires. The first such included 
file has some functions, puts out a header and does an echo, and calls 
set_error_handler. It's in the second included file that the semicolon is 
missed off (inside yet another function).

I would have expected that the results sent back would just consist of the 
Parse error: message, but for some reason the echo done in the first included 
file shows up as well (this is important as it frames the parse error message 
for me).

Is this the expected behaviour? The doc for set_error_handler says you can't 
use it to recover from E_PARSE and the like, and the function I supply to it 
doesn't appear to be called. I was just surprised that the initial echo 
statement's output made it back to the JavaScript side.

(I obviously don't expect to have parse errors show up in production, but 
having them nicely visible and logged during testing is useful)

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Parse errors

2012-03-18 Thread Simon J Welsh
On 19/03/2012, at 6:32 AM, Tim Streater wrote:

 After recently omitting a semicolon from the end of a statement, and having 
 the result be a JavaScript error in an odd place, I'm trying to pin down just 
 what PHP does with such errors. I made a small test script to run at CLI, 
 which does some echoes and then, after that, I miss out a semicolon. On the 
 command line, all I get is the parse error message with line number.
 
 The script where I'd left the semicolon out of my production code is reached 
 via AJAX, and sends some results back. It consists of a number of functions, 
 then the main code appears, starting with two requires. The first such 
 included file has some functions, puts out a header and does an echo, and 
 calls set_error_handler. It's in the second included file that the semicolon 
 is missed off (inside yet another function).
 
 I would have expected that the results sent back would just consist of the 
 Parse error: message, but for some reason the echo done in the first included 
 file shows up as well (this is important as it frames the parse error message 
 for me).
 
 Is this the expected behaviour? The doc for set_error_handler says you can't 
 use it to recover from E_PARSE and the like, and the function I supply to it 
 doesn't appear to be called. I was just surprised that the initial echo 
 statement's output made it back to the JavaScript side.
 
 (I obviously don't expect to have parse errors show up in production, but 
 having them nicely visible and logged during testing is useful)
 
 --
 Cheers  --  Tim

This is expected. The error doesn't occur to the second file is included, so 
everything in the first included file is parsed and run before execution is 
halted.
---
Simon Welsh
Admin of http://simon.geek.nz/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parse errors

2012-03-18 Thread Tim Streater
On 18 Mar 2012 at 17:46, Simon J Welsh si...@welsh.co.nz wrote: 

 This is expected. The error doesn't occur to the second file is included, so
 everything in the first included file is parsed and run before execution is
 halted.

Simon,

Thanks for that. Looks like I should be able to catch most places where an 
error might occur.

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Parse Errors with 5.2 on Linux

2006-11-07 Thread Michael Caplan
Hi there,

 

I just installed PHP 5.2 on a linux server (compiled from source), and
am having some strange problems with a script that is reporting a fatal
parse error:

 

Parse error: syntax error, unexpected $end in /xxx/xxx/xxx/functions.php
on line 1213

 

This very script parses just a-okay under PHP 5.1.6 (linux), and,
mysteriously, 5.2 on windows. 

 

I'm sure that the file is identical across all three servers.  The file
is pulled from a subversion repository, so it should be identical.  Any
ideas?

 

Thanks,

 

Mike

 



Re: [PHP] Parse Errors with 5.2 on Linux

2006-11-07 Thread Richard Lynch
On Tue, November 7, 2006 11:30 am, Michael Caplan wrote:
 I just installed PHP 5.2 on a linux server (compiled from source), and
 am having some strange problems with a script that is reporting a
 fatal
 parse error:

 Parse error: syntax error, unexpected $end in
 /xxx/xxx/xxx/functions.php
 on line 1213

 This very script parses just a-okay under PHP 5.1.6 (linux), and,
 mysteriously, 5.2 on windows.

 I'm sure that the file is identical across all three servers.  The
 file
 is pulled from a subversion repository, so it should be identical.
 Any
 ideas?

That usually means an unmatched { or ( or  or ' etc...

So, basically, I'd suggesting copying the files over by hand with FTP
or something and doing a 'diff' to be 100% sure you have the whole
file.

It's also remotely possible that something changed in 5.2...

I never have understood why it was kosher to leave the final ? off,
for example, so maybe that changed. :-)  [I doubt it]

At any rate, you have to confirm that the file *IS* complete first.

After that, post the file if you can, or we've got nothing to say
about it, really...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Parse Errors with 5.2 on Linux

2006-11-07 Thread Michael Caplan
Hi Richard,

Thanks for the reply.  I tracked the problem down to short tags being
turned off in the php.ini (I know, short tags, bad, bad).  That fixed
it.

Thanks,

Mike


-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 07, 2006 1:39 PM
To: Michael Caplan
Cc: php-general@lists.php.net
Subject: Re: [PHP] Parse Errors with 5.2 on Linux

On Tue, November 7, 2006 11:30 am, Michael Caplan wrote:
 I just installed PHP 5.2 on a linux server (compiled from source), and
 am having some strange problems with a script that is reporting a
 fatal
 parse error:

 Parse error: syntax error, unexpected $end in
 /xxx/xxx/xxx/functions.php
 on line 1213

 This very script parses just a-okay under PHP 5.1.6 (linux), and,
 mysteriously, 5.2 on windows.

 I'm sure that the file is identical across all three servers.  The
 file
 is pulled from a subversion repository, so it should be identical.
 Any
 ideas?

That usually means an unmatched { or ( or  or ' etc...

So, basically, I'd suggesting copying the files over by hand with FTP
or something and doing a 'diff' to be 100% sure you have the whole
file.

It's also remotely possible that something changed in 5.2...

I never have understood why it was kosher to leave the final ? off,
for example, so maybe that changed. :-)  [I doubt it]

At any rate, you have to confirm that the file *IS* complete first.

After that, post the file if you can, or we've got nothing to say
about it, really...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parse Errors with 5.2 on Linux

2006-11-07 Thread Stut

Richard Lynch wrote:

I never have understood why it was kosher to leave the final ? off,
for example, so maybe that changed. :-)  [I doubt it]


Certainly hasn't changed, and I hope it never does. Having to find an 
errant space or carriage return at the end of an include file that is 
one of nearly 100 that get included in a script has taught me that there 
is no greater feature in PHP!! I never use a closing ? if PHP script is 
the last thing in a file - less headaches all around.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parse Errors with 5.2 on Linux

2006-11-07 Thread Robert Cummings
On Tue, 2006-11-07 at 21:18 +, Stut wrote:
 Richard Lynch wrote:
  I never have understood why it was kosher to leave the final ? off,
  for example, so maybe that changed. :-)  [I doubt it]
 
 Certainly hasn't changed, and I hope it never does. Having to find an 
 errant space or carriage return at the end of an include file that is 
 one of nearly 100 that get included in a script has taught me that there 
 is no greater feature in PHP!! I never use a closing ? if PHP script is 
 the last thing in a file - less headaches all around.

Hear, hear! And the word from internals a few years ago was that it was
an intended feature for exactly that reason.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Parse Errors

2002-12-14 Thread Andy Turegano
I am a PHP beginner so this error may be a stupid one. Anyway, I'm
trying to write a simple addition script. The client enters two numbers,
then my script (adder.php) adds them. However, when the script is run, I
get Parse Error On Line 3 I have no idea exactly what I have done wrong.
Here is the script.

?
print (Your first number is:$firstnumber\n)
print (Your second number is:$secondnumber\n)
$answer=$firstnumber+$second number
echo (The answer is: $answer\n)
?

Any help would be greatly appreciated. Thank you.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Parse Errors

2002-12-14 Thread DL Neil
Andy,

 I am a PHP beginner so this error may be a stupid one. Anyway, I'm
 trying to write a simple addition script. The client enters two numbers,
 then my script (adder.php) adds them. However, when the script is run, I
 get Parse Error On Line 3 I have no idea exactly what I have done wrong.
 Here is the script.

 ?
 print (Your first number is:$firstnumber\n)
 print (Your second number is:$secondnumber\n)
 $answer=$firstnumber+$second number
 echo (The answer is: $answer\n)
 ?

 Any help would be greatly appreciated. Thank you.


PHP code lines must end with a semi-colon (;).
Also, HTML newlines are br (not \n)
Some PHPs won't like the short tags, recommend: ?PHP

Regards,
=dn


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Parse errors: path?

2002-09-03 Thread Wm

I'm getting a parse error with this PHP statement:

?php $path = '/usr/local/plesk/apache/vhosts/.../httpdocs/thumbnails/';
$dir = opendir($path) or die(Could not open $dir);
while ($file = readdir($dir)){
if (stristr($file, 'jpg') || stristr($file, 'jpeg')){
echo A HREF=/enlargements/$file$file/ABR\n;
}
  }
  ?
The browser is showing me the following error though, with a changed path:

Parse error: parse error in
/usr/local/psa/home/vhosts/.../httpdocs/fashion.php on line 144

That's the only PHP in the entire page, so the error has to be in there
somewhere.  My webhost mapped/aliased my old path to a new directory when
they upgraded my server.  Does anyone see any errors in the PHP, or should I
be troubleshooting the path info???

Wm






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] parse errors not displayed (2nd time I ask!)

2002-04-29 Thread Pedro Garre

*This message was transferred with a trial version of CommuniGate(tm) Pro*
Hi,

I am sorry I ask this for a second time. 
Come on guys ! I am sure somebody can help, please 

I set my own error handler. It is in a file general_includes.php
(please find it below) and all pages do a require on it.
It works Ok with the exception of parse errors. They are not trapped by
my error handler (which I know it's the expected behaivor) but they
don't either show up in the browser.

My php.ini file has:
display_errors = On
error_reporting = E_ALL  E_NOTICE

And general_includes.php is:
?php

// Esto se ejecutara en todos los ficheros que incluyan a este fichero
error_reporting( E_ALL ^ E_NOTICE );
$old_error_handler = set_error_handler(userErrorHandler);

function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
{
  $dt = date(d-m-Y H:i:s);

  // Paso del path
  $filename = basename ( $filename );

  // Define an assoc array of error string. In reality the only entries
we should 
  // consider are 2,8,256,512 and 1024
  $errortype = array (
  1   =  Error,
  2   =  Warning,
  4   =  Parsing Error,
  8   =  Notice,
  16  =  Core Error,
  32  =  Core Warning,
  64  =  Compile Error,
  128 =  Compile Warning,
  256 =  User Error,
  512 =  User Warning,
  1024=  User Notice
  );

  // Errors for which execution can go on.
  $errores_suaves = array(E_WARNING, E_NOTICE, E_USER_NOTICE);

  $err = errorentry\n;
  $err .= \tdatetime.$dt./datetime\n;
  $err .= \terrornum.$errno./errornum\n;
  $err .= \terrortype.$errortype[$errno]./errortype\n;
  $err .= \terrormsg.$errmsg./errormsg\n;
  $err .= \tscriptname.$filename./scriptname\n;
  $err .= \tscriptlinenum.$linenum./scriptlinenum\n;

  $err .= /errorentry\n\n;

  // For testing. NOTICE errors do not disturb the browser but are
immediatly shown
  // to the programmer. Remaining errors are displayed in the browser.
  if ( ( $errno == E_USER_NOTICE ) || ( $errno == E_NOTICE ) )
system (echo $errno $errortype[$errno] $errmsg $filename $linenum 
| write pedro pts/0 );
  else
echo br=br$err brbr;

  // My own log method, which eventualy sends an email
  logea ( C_ERROR_DEL_HANDLER, 0, $filename, $err );

  // Stop processing if serious error
  if ( ! in_array($errno, $errores_suaves) )
die(Error Interno. Por favor pruebe más tarde);
 }
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] parse errors not displayed (2nd time I ask!)

2002-04-29 Thread 1LT John W. Holmes

Just fix your parse errors. Who cares what error handler it goes to.

Are you going to release code with parse errors in it and do you really want
to get an email each time someone gets one?

---John Holmes...

- Original Message -
From: Pedro Garre [EMAIL PROTECTED]
To: php-general [EMAIL PROTECTED]
Sent: Monday, April 29, 2002 5:37 PM
Subject: [PHP] parse errors not displayed (2nd time I ask!)


 *This message was transferred with a trial version of CommuniGate(tm) Pro*
 Hi,

 I am sorry I ask this for a second time.
 Come on guys ! I am sure somebody can help, please 

 I set my own error handler. It is in a file general_includes.php
 (please find it below) and all pages do a require on it.
 It works Ok with the exception of parse errors. They are not trapped by
 my error handler (which I know it's the expected behaivor) but they
 don't either show up in the browser.

 My php.ini file has:
 display_errors = On
 error_reporting = E_ALL  E_NOTICE

 And general_includes.php is:
 ?php

 // Esto se ejecutara en todos los ficheros que incluyan a este fichero
 error_reporting( E_ALL ^ E_NOTICE );
 $old_error_handler = set_error_handler(userErrorHandler);

 function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars)
 {
   $dt = date(d-m-Y H:i:s);

   // Paso del path
   $filename = basename ( $filename );

   // Define an assoc array of error string. In reality the only entries
 we should
   // consider are 2,8,256,512 and 1024
   $errortype = array (
   1   =  Error,
   2   =  Warning,
   4   =  Parsing Error,
   8   =  Notice,
   16  =  Core Error,
   32  =  Core Warning,
   64  =  Compile Error,
   128 =  Compile Warning,
   256 =  User Error,
   512 =  User Warning,
   1024=  User Notice
   );

   // Errors for which execution can go on.
   $errores_suaves = array(E_WARNING, E_NOTICE, E_USER_NOTICE);

   $err = errorentry\n;
   $err .= \tdatetime.$dt./datetime\n;
   $err .= \terrornum.$errno./errornum\n;
   $err .= \terrortype.$errortype[$errno]./errortype\n;
   $err .= \terrormsg.$errmsg./errormsg\n;
   $err .= \tscriptname.$filename./scriptname\n;
   $err .= \tscriptlinenum.$linenum./scriptlinenum\n;

   $err .= /errorentry\n\n;

   // For testing. NOTICE errors do not disturb the browser but are
 immediatly shown
   // to the programmer. Remaining errors are displayed in the browser.
   if ( ( $errno == E_USER_NOTICE ) || ( $errno == E_NOTICE ) )
 system (echo $errno $errortype[$errno] $errmsg $filename $linenum
 | write pedro pts/0 );
   else
 echo br=br$err brbr;

   // My own log method, which eventualy sends an email
   logea ( C_ERROR_DEL_HANDLER, 0, $filename, $err );

   // Stop processing if serious error
   if ( ! in_array($errno, $errores_suaves) )
 die(Error Interno. Por favor pruebe más tarde);
  }
 ?

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php