Changes

From Studiosg
Jump to navigationJump to search
32 bytes removed ,  22:10, 23 December 2015
Links update and some minor fixes. Moreover the new syntax highlight extension was enabled
Line 2: Line 2:       −
Languages: '''English''' - [http://www.giustetti.net/wiki/index.php?title=php_debug Italiano]
+
Languages: '''English''' - [[php_debug | Italiano]]
    
----
 
----
Line 12: Line 12:       −
== PHP language ==
+
== PHP Language ==
    
PHP is a general purpose programming language aimed for fast script development, well suited for producing '''dynamic web pages'''. In this specific configuration PHP is executed on '''a remote server''' where it generates HTML pages then sent to a web browser. Users requesting web pages will receive them without any sign of server executed PHP code.
 
PHP is a general purpose programming language aimed for fast script development, well suited for producing '''dynamic web pages'''. In this specific configuration PHP is executed on '''a remote server''' where it generates HTML pages then sent to a web browser. Users requesting web pages will receive them without any sign of server executed PHP code.
Line 19: Line 19:       −
== PHP development ==
+
== PHP Development ==
    
Whatever the reason to use PHP, writing code proves to be a fairly simple task and requires neither specific tools nor development environments, but only:
 
Whatever the reason to use PHP, writing code proves to be a fairly simple task and requires neither specific tools nor development environments, but only:
Line 29: Line 29:       −
== PHP and syntax analysis ==
+
== PHP and Syntax Analysis ==
    
PHP bare installation provides some tools useful when searching trough the source code for errors. Executing a '''syntax analysis''' of PHP code is a fairly straightforward task provided local access to the scripts is granted. To check the syntax of script hello_world.php placed inside directory /home/sviluppo/php/ open a '''shell''' or a '''similar terminal emulator''' an move to the directory:
 
PHP bare installation provides some tools useful when searching trough the source code for errors. Executing a '''syntax analysis''' of PHP code is a fairly straightforward task provided local access to the scripts is granted. To check the syntax of script hello_world.php placed inside directory /home/sviluppo/php/ open a '''shell''' or a '''similar terminal emulator''' an move to the directory:
Line 54: Line 54:     
''hello_world.php - Listing 1'': Contains many syntax errors.
 
''hello_world.php - Listing 1'': Contains many syntax errors.
 +
<syntaxhighlight lang="php">
 
   <?php
 
   <?php
 
       echo '<html>'
 
       echo '<html>'
Line 60: Line 61:  
       echo '  </head>";
 
       echo '  </head>";
 
       echo'  <body>';
 
       echo'  <body>';
       echo '    <nowiki><p>Hello World</p></nowiki>'; ?>
+
       echo '    <p>Hello World</p>'; ?>
 
       echo '</body>";
 
       echo '</body>";
 
       echo '</html>';
 
       echo '</html>';
 
   ?>
 
   ?>
 +
</syntaxhighlight>
 
''hello_world.php - Listing 2'': The first parser signaled bug was resolved.
 
''hello_world.php - Listing 2'': The first parser signaled bug was resolved.
 +
<syntaxhighlight lang="php">
 
   <?php
 
   <?php
 
       echo '<html>';
 
       echo '<html>';
Line 71: Line 74:  
       echo '  </head>";
 
       echo '  </head>";
 
       echo'  <body>';
 
       echo'  <body>';
       echo '    <nowiki><p>Hello World</p></nowiki>'; ?>
+
       echo '    <p>Hello World</p>'; ?>
 
       echo '</body>";
 
       echo '</body>";
 
       echo '</html>';
 
       echo '</html>';
 
   ?>
 
   ?>
 +
</syntaxhighlight>
 
''hello_world.php - Listing 3'': Correct syntax.
 
''hello_world.php - Listing 3'': Correct syntax.
 +
<syntaxhighlight lang="php">
 
   <?php
 
   <?php
 
       echo "<html>\n";
 
       echo "<html>\n";
Line 82: Line 87:  
       echo "  </head>\n";
 
       echo "  </head>\n";
 
       echo "  <body>\n";
 
       echo "  <body>\n";
       echo "      <nowiki><p>Hello World</p></nowiki>'; ?>
+
       echo "      <p>Hello World</p>\n";
 
       echo "  </body>\n";
 
       echo "  </body>\n";
 
       echo "</html>\n";
 
       echo "</html>\n";
 
   ?>
 
   ?>
 +
</syntaxhighlight>
      −
== PHP and variable content ==
+
== PHP and Variable Content ==
    
Syntax analysis proves to be an useful tool for error spotting, but it mainly highlights mistypings and missing characters while typing code. Syntax errors are fairly easy to spot and correct. '''Logic errors''' are usually more difficult to find and resolve. Logic errors only show up while the code is in execution. To understand such errors requires to follow the code flow through the parsed files, understand their order of execution and print out a list of variables and their respective content. PHP offers a relatively scarce number of tools to perform such task: '''backtrace and dump''' functions.
 
Syntax analysis proves to be an useful tool for error spotting, but it mainly highlights mistypings and missing characters while typing code. Syntax errors are fairly easy to spot and correct. '''Logic errors''' are usually more difficult to find and resolve. Logic errors only show up while the code is in execution. To understand such errors requires to follow the code flow through the parsed files, understand their order of execution and print out a list of variables and their respective content. PHP offers a relatively scarce number of tools to perform such task: '''backtrace and dump''' functions.
Line 123: Line 129:  
# Repeating the above tasks until a bug is found and resolved.
 
# Repeating the above tasks until a bug is found and resolved.
 
# Removing all the added lines of code to restore the program flow.
 
# Removing all the added lines of code to restore the program flow.
The procedure can result difficult and requires a lot of effort and time. It surely would be better to '''follow parser executed code flow without the need to update it'''. This proves to be impossible without installing and configuring some additional tools. Many of such freely available tools are based on xdebug, a software that will be thee subject of a future article dealing with its many features, installation and configuration procedures and bindings with some external developers tools.
+
The procedure can result difficult and requires a lot of effort and time. It surely would be better to '''follow parser executed code flow without the need to update it'''. This proves to be impossible without installing and configuring some additional tools. Many of such freely available tools are based on [[En/xdebug|xdebug]], a software that will be thee subject of a future article dealing with its many features, installation and configuration procedures and bindings with some external developers tools.
      Line 138: Line 144:  
----
 
----
   −
Languages: '''English''' - [http://www.giustetti.net/wiki/index.php?title=php_debug Italiano]
+
Languages: '''English''' - [[php_debug | Italiano]]

Navigation menu