Advertisement
Shaun_B

PHP Programming Principle Examples

Apr 29th, 2020
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php
  2.     /* Pre-defined 'symbols' */
  3.     /* ALL UPPER CASE - use underscore for linking nouns or words */
  4.     define('COMPANY_NAME', 'Chris Baldy PLC');
  5.     define('TELEPHONE_NUMBER', '0161 011 1001');
  6.    
  7.     /* Variable */
  8.     /* Always start with $ - lower case for the first word, no spaces, starting word thereafter will
  9.     always be upper-case first */
  10.     $header = COMPANY_NAME . ' Call today on: ' . TELEPHONE_NUMBER; /* string type */
  11.    
  12.     echo $header;
  13.    
  14.     $header = 'This is not a header'; /* still a string */
  15.    
  16.     echo PHP_EOL . $header;
  17.    
  18.     $header = 22.44 * 22; /* number */
  19.    
  20.     echo PHP_EOL . $header;
  21.    
  22.     /* Variable types */
  23.     /* integers - whole numbers */
  24.     /* strings - collections of letters */
  25.     /* floats - real number */
  26.     /* objects - mixed types */
  27.     /* arrays - mixed types */
  28.    
  29.     if(COMPANY_NAME === 'Chris Baldy PLC') {
  30.         echo PHP_EOL . 'Best offers today - call now';
  31.        
  32.        
  33.         echo PHP_EOL . 'Extra code';
  34.     } else {
  35.        
  36.     }
  37.    
  38.     /* PHP maths */
  39.    
  40.     /* / - division */
  41.     /* * - multiplication */
  42.    
  43.    
  44.     echo PHP_EOL . 10 / 2;
  45.    
  46.    
  47.     /* @see https://www.php.net/ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement