Simple header file that doesn't work rightly...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MM

    Simple header file that doesn't work rightly...

    Hi everybody,
    what do you think about this problem?
    I want to create a HTML header file with 2 variables, as below:
    -----------------------------
    $title = "Title of document";
    $style = "./style/style.css";

    print<<<HED
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
    www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>$title </title>
    <meta http-equiv = 'Content-Type' content='text/html;
    charset=iso-8859-1'>
    <meta http-equiv = 'Content-Style-Type' content = 'text/css'>
    <link href = '$style' rel = 'stylesheet' type = 'text/css'>
    </head>
    <body>
    HED;
    -----------------------------

    It doesn't work rightly: $title is printed... $style not.
    I have tried to modify everything and I have found it only works as
    below:

    ....
    <link href = './style/style.css' rel = 'stylesheet' type = 'text/css'>
    ....

    i.e. it works only if I write the string with file path directly.
    But... I want a variable!

    [NOTE: the problem isn't HEREDOC, it's the same with print("...") or
    echo "..."]

    Suggestions?
    Thanks.

    Regards,
    MM

  • iktorn

    #2
    Re: Simple header file that doesn't work rightly...

    MM napisał(a):
    Hi everybody,
    what do you think about this problem?
    I want to create a HTML header file with 2 variables, as below:
    -----------------------------
    $title = "Title of document";
    $style = "./style/style.css";
    >
    print<<<HED
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
    www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>$title </title>
    <meta http-equiv = 'Content-Type' content='text/html;
    charset=iso-8859-1'>
    <meta http-equiv = 'Content-Style-Type' content = 'text/css'>
    <link href = '$style' rel = 'stylesheet' type = 'text/css'>
    </head>
    <body>
    HED;
    -----------------------------
    >
    I don't see any problems in this piece of code on my computer.
    Why don't you simply use

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title><?php echo $title; ?></title>
    <meta http-equiv = 'Content-Type' content='text/html; charset=iso-8859-1'>
    <meta http-equiv = 'Content-Style-Type' content = 'text/css'>
    <link href = "<?php echo $style; ?>" rel = 'stylesheet' type = 'text/css'>
    </head>
    <body>

    ?

    --
    Wiktor Walc

    Comment

    • MM

      #3
      Re: Simple header file that doesn't work rightly...

      I don't see any problems in this piece of code on my computer.
      Why don't you simply use
      >
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <title><?php echo $title; ?></title>
      <meta http-equiv = 'Content-Type' content='text/html; charset=iso-8859-1'>
      <meta http-equiv = 'Content-Style-Type' content = 'text/css'>
      <link href = "<?php echo $style; ?>" rel = 'stylesheet' type = 'text/css'>
      </head>
      <body>
      >
      Because it's really a part of class file that has whole code within <?
      php and ?tag.

      Comment

      • Johnny

        #4
        Re: Simple header file that doesn't work rightly...


        "MM" <mazzimil@gmail .comwrote in message
        news:1181657469 .040889.86690@i 13g2000prf.goog legroups.com...
        Hi everybody,
        what do you think about this problem?
        I want to create a HTML header file with 2 variables, as below:
        -----------------------------
        $title = "Title of document";
        $style = "./style/style.css";
        >
        print<<<HED
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
        www.w3.org/TR/html4/loose.dtd">
        <html>
        <head>
        <title>$title </title>
        <meta http-equiv = 'Content-Type' content='text/html;
        charset=iso-8859-1'>
        <meta http-equiv = 'Content-Style-Type' content = 'text/css'>
        <link href = '$style' rel = 'stylesheet' type = 'text/css'>
        </head>
        <body>
        HED;
        -----------------------------
        >
        It doesn't work rightly: $title is printed... $style not.
        I have tried to modify everything and I have found it only works as
        below:
        >
        ...
        <link href = './style/style.css' rel = 'stylesheet' type = 'text/css'>
        ...
        >
        i.e. it works only if I write the string with file path directly.
        But... I want a variable!
        >
        [NOTE: the problem isn't HEREDOC, it's the same with print("...") or
        echo "..."]
        >
        Suggestions?
        Thanks.
        >
        Regards,
        MM
        >
        works for me... I did this:
        file ./style/style.css:
        h1 {
        border: 1px solid red;
        font-size: 50%;
        }
        file 6.php:
        <?php
        $title = "Title of document";
        $style = "./style/style.css";

        print<<<HED
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
        www.w3.org/TR/html4/loose.dtd">
        <html>
        <head>
        <title>$title </title>
        <meta http-equiv = 'Content-Type' content='text/html;
        charset=iso-8859-1'>
        <meta http-equiv = 'Content-Style-Type' content = 'text/css'>
        <link href = '$style' rel = 'stylesheet' type = 'text/css'>
        </head>
        <body>
        HED;
        print<<<BOD
        <h1>YO!</h1>
        </body>
        </html>

        BOD;
        ?>

        and it works just fine, the red border shows and the text is 50% of regular
        h1


        Comment

        Working...