Skip to content
Marie-Louise edited this page Sep 14, 2018 · 46 revisions

PHP: Hypertext Preprocessor

How PHP works

when a user visits a dynamic site that built using PHP, the page sends a request to the server and then the server sends a request to the PHP Zend engine for processing. If there is a database the the Zend engine will send a request to it and this will process the results

PHP is an embedded language, so the code is embedded / mixed in HTML markup. PHP is a server side technology. after its been processed or parsed - it outputs only HTML and text.

Common features in PHP scripts

  • Variables act as placeholders for unknown or changing values. Variables documentation
  • Arrays hold multiple values
  • Conditional statements are used to make decisions
  • Loops are used to perform repetitive tasks

PHP files must be stored inside the server root folder (the names can vary):

  • htdocs

  • www

  • wwwroot

  • public_html

Basics

These two statements are used to display values in the browser. The main difference between them is that:

Echo can display a series of values separated by commas.

echo

Print can display only a single values

print

FILE : footer.tpl.php /sites/all/modules/custom/corp_markup/theme/sitewide/footer.tpl.php/footer.tpl.php

 <ul class="nav-social__list">
      <?php foreach($variables['social'] as $item): ?>
        <li class="nav-social__list__item">
          <a href="<?php print $item['url']; ?>"
             title="Follow us on <?php print $item['title']; ?>"
             class="nav-social__list__item__link nav-social__icon nav-social__icon--<?php print 
$item['class_modifier']; ?>"><?php
                 print "Wellcome on " . $item['title'];
          ?></a>
        </li>
      <?php endforeach; ?>
    </ul>

In order to render the desired labels to the social media icons, it was necessary to add the following code (the full code block is above) :

 print "Wellcome on " . $item['title'];

OTHER FILES :

/sites/all/modules/custom/corp_markup/theme/misc/social_media_share.tpl.php/social_media_share.tpl.php /sites/all/modules/custom/corp_markup/theme/sitewide/footer.tpl.php/footer.tpl.config.js /sites/all/modules/custom/corp_markup/corp_markup.module /sites/all/modules/custom/corp_sitewide/plugins/content_types/footer.inc

Clone this wiki locally