Drupal is build up on PHP script. hence it is necessary to understand some basic PHP syntax to start with drupal. Though PHP has a large domain and obviously it is quite hard to cover it in a sinble blog post. So I am mentioning some essential parts of PHP that is required for a basic drupal development. If you are non-developer, this will help you to understand drupal well.
The 5 topics are required to understand in PHP for drupal as they are used elsewhere in drupal codebase. They are as follows.
1. PHP Variables
2. Condition and Loops
5. Class and Object concept.
Generally PHP scripts has an extention .php, however in drupal codes can be written using any extensions like .module, .inc etc. But scripting inside these files follows the php syntax and its rules. PHP script starts with <?php tag but usually does not require to end with a ?> . The reason behind this is in any open source package (Drupal, Joomla etc.) in PHP, there are lots of files which are included in execution time. As PHP is an interpreted language, PHP parser processes the internal script between <?php and ?> If accidentally any html markup appears between two subsequent <?php tags, PHP parser also processes them. This slows down the execution speed and also there is a chance to get unnecessary whitespaces and characters in the output. So ?> tag is not required for any scripting page in drupal. That ensures that only pure php script is processed by PHP parser, not HTML markup.
Each php statement ends with ";" make sure to give this after every statement in the code.
In the next post I will discuss about the upper-mentioned five topics in details so that you can get an idea about PHP scripting methods and its syntaxes to start up drupal development.