ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

copy books .....in PHP?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • copy books .....in PHP?

    A copy book



    RPG
    PHP Code:
         Ã€*
         
    À* Copy book API data structures
         
    À*

            
    d/COPY QSYSINC/QRPGLESRC,QUSRUSAT
            d
    /COPY QSYSINC/QRPGLESRC,QUSLMBR
            d
    /COPY QSYSINC/QRPGLESRC,QUSGEN 
    PHP

    Below within the directory includes is another
    PHP page called head.php .... I would say that
    inside of head.php would be all the header info
    for the site....this way you could add this to
    the top of each page and your site would remain
    consistant. Just by modifying this one page
    you could change the look of your entire site.

    Some where within the head.php would most likely
    be another include to a connection php page that
    connects to the database. We will look at this
    later.

    PHP Code:
     <?php include("includes/head.php");?>
    require_once()--or-- include_once() makes sure that a
    script(page) is only included once....
    After the file is included once PHP will ignore and new
    statements that include this file.

    PHP Code:
    require_once('phpSniff.class.php'); 

    Lets test this here is the first PHP page.
    PHP Code:
     <?
    include("header.php");

      // same comment id "//" as free RPG
      // this will write the a header line 6 times
      // because there are only 6 header sizes <h1>,<h2>,<h3>,<h4>,<h5>,<h6>
      // notice the "." after the "This is header" this is for catnation of 
      // the test and the variable counter..(Variables are identified by the "$") 
       
        for ($counter = 6; $counter > 0  ; $counter--)
        {
           
           print "<h$counter>";
           print "This is header" .$counter . "<br>" ;
           print "</h$counter>";    
        } 

      ?>


    </body>
    </html>
    here is header.php notice the "\" prior to the double quotes
    this is required to escape the double quotes which indicate
    start and end of the print string.... Also take not that
    I just double quoted the html text ...I could have just
    as easily keyed it in as straight HTML and moved the include
    outside (above) the <? (start php) ..... image below is
    what we get......

    PHP Code:

    <?

    print "
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">

    <html>
    <head>
        <title>Untitled</title>
    </head>
    \"some random text\" 
    <body>";

    ?>
    if you viewed source from the browser it would look like this
    notice the include is gone and in its place is the contents of
    the header.php page.
    PHP Code:
     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <
    html>
    <
    head>
        <
    title>Untitled</title>
    </
    head>
    "some random text" 
    <body><h6>This is header6<br></h6><h5>This is header5<br></h5>
    <
    h4>This is header4<br></h4><h3>This is header3<br></h3>
    <
    h2>This is header2<br></h2><h1>This is header1<br></h1>

    </
    body>
    </
    html
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: copy books .....in PHP?

    Originally posted by jamief View Post
    A copy book

    here is header.php notice the "\" prior to the double quotes
    this is required to escape the double quotes which indicate
    start and end of the print string.... Also take not that
    I just double quoted the html text ...I could have just
    as easily keyed it in as straight HTML and moved the include
    outside (above) the <? (start php) ..... image below is
    what we get......

    PHP Code:

    <?

    print "
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">

    <html>
    <head>
        <title>Untitled</title>
    </head>
    \"some random text\" 
    <body>";

    ?>
    I find it easier myself to enclose it inside single quotes, then you don't need to use the slash "\" to escape the quote sign - see below ...

    IMHO this makes it easier to debug/read later as what you see is what you get, no mental juggling with slashes.

    PHP Code:
    <?

    print '
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
        <title>Untitled</title>
    </head>
    "some random text" 
    <body>';

    ?>
    GC
    Greg Craill: "Life's hard - Get a helmet !!"

    Comment


    • #3
      Re: copy books .....in PHP?

      You can mix and match php with html like this

      PHP Code:
      <?php
      # Here's a block of PHP code, when we exit this the text below gets output
      # as if it was in a print statement
      ?>

      <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">

      <html>
      <head>
          <!-- We can jump back into PHP at any time -->
          <title><?php echo 'Title'?></title>
      </head>
      <body>
      <p>some random text</p>
      </body>
      </html>
      <?php
      # We can keep jumping in and out of php code like this
      ?>
      Ben

      Comment

      Working...
      X