Welcome Guest, Not a member yet? Register   Sign In
Basic PHP question
#3

(This post was last modified: 08-06-2019, 11:13 PM by John_Betong.)

I have started using PHP to convert all HTML content into PHP strings.

PHP HereDoc is great for making the strings more readable: 

Do you think it is worth making the extra effort? I do because most of my time is spent debugging Sad

PHP Code:
<?php  
  declare
(strict_types=1);
 
 error_reporting(-1);
 
 ini_set('display_errors''1');
 
 ini_set('display_html_errors''1');

$title    'Title goes here';
$aArticle = [
 
 0,
 
 0.00,
 
 NULL,
 
 '',
 
 '   ',
 
 '&nbsp;'// asdf
 
 "",
 
 "   ",
 
 "&nbsp;",
 
 'this is the article'
];

// DEBUG 
 
 $DEBUG    '<pre>' .print_r($aArticleTRUE) .'</pre>';
 
 $rand     count($aArticle) -1;
 
 $iRand    mt_rand(0$rand ) ;

// ARTICLE
 
 $article  $aArticle[$iRand];
 
 $count    count($aArticle);
 
 $article  = empty($article) ? '' '<p>' .$article .'</p>';

// PHP HEREDOC string
 
 $tmp = <<< ____EOT
    <div style="height:8.8em">
      <h1> My blog </h1>
      <h2> 
$title  </h2>
      
$article
      <hr>
    </div>  
____EOT;
 
 echo $tmp;

// PHP HEREDOC string
 
 $DEBUG = <<< ____EOT
    <dl>
      <dt> Debug: </dt>
      <dd> Selection: 
$iRand </dd>
      <dd> 
$DEBUG </dd>
    </dl>
____EOT;
 
 echo $DEBUG
Reply


Messages In This Thread
Basic PHP question - by ronniebel - 08-06-2019, 04:22 PM
RE: Basic PHP question - by includebeer - 08-06-2019, 05:14 PM
RE: Basic PHP question - by John_Betong - 08-06-2019, 11:12 PM
RE: Basic PHP question - by albertleao - 08-06-2019, 11:20 PM
RE: Basic PHP question - by includebeer - 08-07-2019, 02:57 AM
RE: Basic PHP question - by dave friend - 08-07-2019, 06:28 AM
RE: Basic PHP question - by John_Betong - 08-08-2019, 09:27 AM
RE: Basic PHP question - by includebeer - 08-08-2019, 10:12 AM
RE: Basic PHP question - by dave friend - 08-08-2019, 12:10 PM
RE: Basic PHP question - by kilishan - 08-08-2019, 02:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB