[support] Within a drupal custom module what is a more efficient way for me to detect and fix any php syntax errors?

CM Lubinski cmc333333 at gmail.com
Thu Apr 15 15:13:58 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you are worried about syntactic errors (rather than logical ones),
you can also run your code through php's lint.

$ php -l mymodule.php

Unfortunately, this only handles one file at a time, but it will tell
you if the code can be included at all.

Best of Luck,
CM Lubinski
- ---
http://cmlubinski.info

William Smith wrote:
> Yeah, turning on error reporting helps tremendously -- I hate to develop in
> an environment with error reporting off.
> 
> Also, there is always the old "print 'got here'; exit;" trick which can help
> when trying to isolate the bad line.
> 
> On Wed, Apr 14, 2010 at 4:01 PM, Earnie Boyd
> <earnie at users.sourceforge.net>wrote:
> 
>> John Mitchell wrote:
>>> I wrote my first php code within a newly created drupal module and I
>>> got it to work.
>>>
>> Firsts are always good.
>>
>>> Initially it was not working (Drupal would not come up) and I did not
>>> know what was wrong so started to take out lines until Drupal finally
>>> came up and that is how I discovered which line had the syntax error.
>>> Once I knew which line it was I fixed the problem and put it back in
>>> the code and drupal came up.
>>>
>> The hard way to debug it. :)
>>
>>> My question is in the future if I have this problem again where Drupal
>>> does not come up because of some php code within a custom module
>>> erroring off what is a more efficient way for me to detect and fix any
>>> php syntax errors?
>>>
>> Any number of ways.  If you're using apache the error would be in the
>> error.log file.  And if you set the php.ini file with a log file or
>> syslog then it would be there.  And then there is the PHP display_errors
>> setting that can be set in .htaccess or settings.php file.
>>
>> .htaccess you would add
>> php_value display_errors 1
>>
>> --
>> Earnie
>> -- http://progw.com
>> -- http://www.for-my-kids.com
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkvHLTIACgkQfzi1OiZiJLCm4wCfUYUSrSdYItU+kwUmK2qgwCsp
OWIAnjbUDsXJWn7qCM66MI9xbVyLgCLc
=K6Lq
-----END PGP SIGNATURE-----


More information about the support mailing list