Difference between revisions of "Sven/PHP"

From Organic Design wiki
(See also)
(http://www.php.net/manual/en/ref.apd.php)
Line 157: Line 157:
 
*[http://www.php.net/manual/en/ref.classobj.php Introspection:Class/Object Functions]
 
*[http://www.php.net/manual/en/ref.classobj.php Introspection:Class/Object Functions]
 
*[http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Scope Resolution Operator (::)]
 
*[http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php Scope Resolution Operator (::)]
 
+
*[http://www.php.net/manual/en/ref.apd.php Advanced php debugger]
 
;Documentation
 
;Documentation
 
*[http://svn.wikimedia.org/doc/ Deoxygen MediaWiki Documentation]
 
*[http://svn.wikimedia.org/doc/ Deoxygen MediaWiki Documentation]

Revision as of 23:04, 13 April 2008

Debugging PHP

Info.svg In MediaWiki there is a profiler that can be set, see MW:How to debug.


Debuggers generally use a W:Stack trace. This can be approximated by using print and die statements in sections of code. The combination of print_r and func_get_args allows you to return an array of args that a function was called with;


<php>

print_r(func_get_args()); </php>

Casting an object of an array builds an array of the properties, mapping property names to values. e.g.

{{{1}}}

outputs;

Array
(
[name] => Fred
[age] => 35
)

Introspection

Info.svg


{{{1}}}

From Sven/Notes, Extension:Fasta.php;

{{{1}}}

PHP errors

To see PHP errors, add this to the very top of LocalSettings.php:

<php>

error_reporting(E_ALL); ini_set("display_errors", 1); </php>

MediaWiki profiler

The article how to debug MediaWiki provides information on setting up the profiler by adding the globals to your LocalSettings.php file;

{{{1}}}

However if you include in an extension;

<php>

include("$IP/includes/GlobalFunctions.php"); wfDebug("This is just testing the debug tracing stuff\n"); </php>

there seems to be no output in the generated log file.

See also

Debugging
http://www.php.net
Documentation
Extensions
Resources