Professional Web Applications Themes

2 <?php sections in one doc? - PHP Development

Hi all, This is a newbie question but I have been struggling with this for ages. I have a doent with 2 separate <?php sections of code. I would like to declare some variables in the first section and then read these in the second but do not seem to be able to do this. Can someone please let me in on how! :) Thanks in advance for the help. Best Regards, David...

  1. #1

    Default 2 <?php sections in one doc?

    Hi all,

    This is a newbie question but I have been struggling with this for ages. I
    have a doent with 2 separate <?php sections of code. I would like to
    declare some variables in the first section and then read these in the
    second but do not seem to be able to do this. Can someone please let me in
    on how! :)

    Thanks in advance for the help.

    Best Regards,
    David


    David Hickman Guest

  2. #2

    Default Re: 2 <?php sections in one doc?

    David Hickman wrote:
    >This is a newbie question but I have been struggling with this for ages. I
    >have a doent with 2 separate <?php sections of code. I would like to
    >declare some variables in the first section and then read these in the
    >second but do not seem to be able to do this. Can someone please let me in
    >on how! :)
    How about some code?

    The following works as expected ...

    <?php
    echo '<hr />';
    $var1 = 'one';
    $var2 = 'two';
    ?>
    <table>
    <tr><th>HTML</th></tr>
    <tr><td>here</td></tr>
    </table>
    <?php
    echo $var1, $var2;
    ?>


    --
    "Yes, I'm positive."
    "Are you sure?"
    "Help, somebody has stolen one of my electrons!"
    Two atoms are talking:
    Pedro Guest

  3. #3

    Default Re: 2 <?php sections in one doc?

    David Hickman wrote:
    > Hi all,
    >
    > This is a newbie question but I have been struggling with this for ages. I
    > have a doent with 2 separate <?php sections of code. I would like to
    > declare some variables in the first section and then read these in the
    > second but do not seem to be able to do this. Can someone please let me in
    > on how! :)
    >
    > Thanks in advance for the help.
    >
    > Best Regards,
    > David
    >
    >
    Can we see a sample? What you're talking about, if I'm reading this
    correctly, is this:

    <?php $a = 3; ?>
    <html>
    <head></head>
    <body>
    <p>Hello everyone. We all know that 2 + 1 = <?php echo $a ?></p>
    </body>
    </html>

    If that's the case, then it should work like a dream. If it's not what
    you're talking about, please attach some sample code.

    Joshua Ghiloni Guest

  4. #4

    Default Re: 2 <?php sections in one doc?

    thanks guys, that was what I meant. I must have something wrong in my code.
    I'll take a look! :)

    Thanks for the help,
    David


    "Joshua Ghiloni" <jdg11SPAM.ME.AND.DIE.cwru.edu> wrote in message
    news:bdq4gm$231$2eeyore.INS.cwru.edu...
    > David Hickman wrote:
    >
    > > Hi all,
    > >
    > > This is a newbie question but I have been struggling with this for ages.
    I
    > > have a doent with 2 separate <?php sections of code. I would like to
    > > declare some variables in the first section and then read these in the
    > > second but do not seem to be able to do this. Can someone please let me
    in
    > > on how! :)
    > >
    > > Thanks in advance for the help.
    > >
    > > Best Regards,
    > > David
    > >
    > >
    >
    > Can we see a sample? What you're talking about, if I'm reading this
    > correctly, is this:
    >
    > <?php $a = 3; ?>
    > <html>
    > <head></head>
    > <body>
    > <p>Hello everyone. We all know that 2 + 1 = <?php echo $a ?></p>
    > </body>
    > </html>
    >
    > If that's the case, then it should work like a dream. If it's not what
    > you're talking about, please attach some sample code.
    >

    David Hickman Guest

Similar Threads

  1. #39463 [NEW]: php.ini sections are ignored
    By RQuadling at GMail dot com in forum PHP Bugs
    Replies: 1
    Last Post: November 10th, 02:35 PM
  2. Contribute 3 Permission Sections
    By DanielKerr in forum Macromedia Contribute General Discussion
    Replies: 11
    Last Post: August 10th, 08:11 PM
  3. Grab ID or DIV sections From ASP
    By Stan Sainte-Rose in forum ASP Components
    Replies: 1
    Last Post: June 16th, 07:48 PM
  4. Preloading different website sections
    By gikicikmaz webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 0
    Last Post: July 12th, 11:37 AM
  5. Using actionscript to move between different sections - how done?
    By dog in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: July 6th, 12:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139