using echo but need something to execute php code

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

    #16
    Re: using echo but need something to execute php code


    "Vince Morgan" <vinhar@REMOVEo ptusnet.com.auw rote in message
    news:46349b51$0 $16555$afc38c87 @news.optusnet. com.au...
    I always make an error :[
    --end output from the include
    this got included by accident by pasting from your post
    ------
    <?php
    echo 'hello';
    ?>
    ---------
    sorry about that


    Comment

    • Jon Slaughter

      #17
      Re: using echo but need something to execute php code

      <snip>
      I think this is what you want and a lot less complicated than eval().
      HTH
      Vince
      >
      I can't do that because I have written a somewhat complicate scheme where
      most of my files are automatically generated.

      Basically I created a script that will take a file that gives the menu items
      for a nav menu and it will generate all the html and files references for
      those links along with adding some code to modify those links depending on
      which page it is at the moment.

      Its not complicated but I don't want to go back at this point in time and
      rewrite it and the two methods are incompatible. (that is, I cannot use
      your way because it would mean I would have to rewrite a lot of stuff).

      Utimately I think it probably would have been easier and maybe its not to
      difficult to actually modify but I don't feel like doing more work than I
      have to at this point. When I rewrite my site I'll try to do a better job
      so I'll wait until I get to that point. But if I can't find a method that
      works then I might have too... luckily that doesn't seem to be the case.

      Thanks,
      Jon


      Comment

      • Jerry Stuckle

        #18
        Re: using echo but need something to execute php code

        Geoff Berrow wrote:
        Message-ID: <5C_Yh.1820$tp5 .373@newssvr23. news.prodigy.ne tfrom Jon
        Slaughter contained the following:
        >
        >Your a dipshit...
        >
        No, that's /you're/ a dipshit.
        >
        >
        >
        >
        Geoff,

        You shouldn't call him a dipshit. That's an insult to dipshits everywhere.

        He's just a typical asshole who doesn't know how to ask a question,
        gives people just the information HE thinks we need to figure out the
        answer HE wants. Then he blames everyone else for his inadequacies.

        It's similar to the philosophy professor who, for the final exam, asks:

        "What is the meaning of",

        then flunks anyone who doesn't know he means:

        "the graffiti scrawled on the wall on the northeast corner of 4th and Main".

        If he were to learn how to ask question properly he would get good answers.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Jerry Stuckle

          #19
          Re: using echo but need something to execute php code

          Jon Slaughter wrote:
          Well, I thought I was clear enough. I think what happens is because I use a
          simple example that many here think there must be a simple solution. I give
          a simple example only to express the problem as concisely as I can instead
          of cluttering it up with things that are irrelevant and, I would assume,
          only cause more confusion. Its like a math problem, If there is something
          I'm trying to solve but the equation is very complicated and I can reduce
          the issue down to a similar but much more simple problem then thats what I
          would do. I believe my original explination was simple and explained the
          problem but I could be wrong. I have gotten a solution from Janwillem which
          probalby will work(haven't tried it yet due to other issues).
          >
          If it was simple as using include then I would have done it. Peopl elike
          Toby and Geoff have a very simplistic view of things and there problem is
          that their ego always ends up showing up.
          >
          In any case, again, I have a file that is essentially html code in it. It
          has a php extension as all my files do. That is not the issue.
          >
          The issue is that I have this file, call it MyFile.php and I want to parse
          it to modify some html code or generate some html code based on some
          context. If I just use include then I have no way of looking at the file?
          >
          If I do
          >
          include 'MyFile.php'
          >
          Then how am I going to modify what I need to modify? Theres no way to get at
          the contents of the file that is loaded do do anything.
          >
          For example, what if MyFile.php is
          >
          <body>
          Hello
          <div class="table"></div>
          <?php
          echo 'hello';
          ?>
          </body>
          >
          REMEMBER THIS IS JUST A SIMPLIFIED EXAMPLE. Obviously if this was what I was
          really trying to do there would be no need to parse it as I could approach
          it differently. (so don't tell me I need to approach it differently because
          its actually more complicated and maybe I did things backwards but its too
          late at this point)
          >
          In any case, now I have a file called AddTable.php that essentially takes
          this file and parses it for <div class="table"an d inserts a table inside
          that div.
          >
          if I simply do
          >
          include 'MyFile.php'
          >
          then how can I parse it?
          >
          if I do
          >
          $file = file_get_conten ts('MyFile.php' );
          >
          Then I can easily parse the string $file and modify it to add the table.
          >
          so after that I now have $file that looks something like
          <body>
          Hello
          <table>
          <tr>
          <td>Blah
          </td>
          </tr>
          </table>
          >
          <?php
          echo 'hello';
          ?>
          </body>
          >
          and when I want to send it to the client,
          >
          echo $file;
          >
          it will not interpret the php code and just send it as text to them (so they
          get exactly what is above in $file instead of
          >
          <body>
          Hello
          <table>
          <tr>
          <td>Blah
          </td>
          </tr>
          </table>
          hello
          </body>
          >
          >
          So I need a way to get $file to interpret the php code before I send it.
          Janwillem has said eval will do it and from looking in the manual it seems
          like it will work. There is also another solution I mentioned in the
          original post that looks like it will work. I might have been able to design
          the site differently and been able to avoid this issue but I didn't and I'm
          not about to start over at this point just because some jack ass(not you)
          gets to confused and doesn't understand the problem.
          >
          In any case I hope to try eval soon as I think it will be the easiest
          solution and do exactly what I need.
          >
          Thanks,
          Jon
          >
          >
          Jon,

          Maybe if you would have explained it this way in the start you would
          have gotten better answers. This is NOT the problem you started with!

          As it is, I can think of a couple of ways to do it. But after seeing
          the way you treat people trying to help you, I'm not inclined to post them.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Toby A Inkster

            #20
            Re: using echo but need something to execute php code

            Jon Slaughter wrote:
            file_get_conten ts($Page)
            parse($Page)
            save($Page)
            include "$Page"
            >
            as it seems uncessary to have to write the page to disk just to include it.
            Mount an area of RAM as a virtual disk.

            --
            Toby A Inkster BSc (Hons) ARCS
            Fast withdrawal casino UK 2025 – Play now & cash out instantly! Discover the top sites for rapid, secure payouts with no delays.

            Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

            * = I'm getting there!

            Comment

            • Jon Slaughter

              #21
              Re: using echo but need something to execute php code


              "Toby A Inkster" <usenet200703@t obyinkster.co.u kwrote in message
              news:1sseg4-q7c.ln1@ophelia .g5n.co.uk...
              Jon Slaughter wrote:
              >
              >file_get_conte nts($Page)
              >parse($Page)
              >save($Page)
              >include "$Page"
              >>
              >as it seems uncessary to have to write the page to disk just to include
              >it.
              >
              Mount an area of RAM as a virtual disk.
              >
              Ok, thats something new, I haven't done anything like that. I'll have to
              look into it.

              Thanks,
              Jon


              Comment

              • Jon Slaughter

                #22
                Re: using echo but need something to execute php code

                >
                Maybe if you would have explained it this way in the start you would have
                gotten better answers. This is NOT the problem you started with!
                >
                It is exactly the problem I started with. I might have not explained as well
                but that is entirely different.
                As it is, I can think of a couple of ways to do it. But after seeing the
                way you treat people trying to help you, I'm not inclined to post them.
                >
                Well, its your choice. I might have overreacted and then that was my fault.
                Now that I look at my original post I can see how it doesn't explain it that
                well. I thought it was clear at the time.. in any case you just have to look
                at the line

                "Is there any command that essentially executes the code and then echo's
                it?"

                you know, Janwillem had no problem with it and he was the first to post. So
                it can't be all that unclear.

                I just don't like people trying to dictate to me how I'm suppose to think or
                what I am thinking about.

                "The answer was correct. It's the question we are having a problem with"

                Thats just total BS. Now maybe I did overreact. If so then I apologize.
                But when I read that I read that Geoff is telling me that my question is
                wrong. I'll be damned if questions are wrong. Questions are not
                propositions. He could have just said "Hey, I don't understand what your
                exactly trying to do." instead of trying to make seem like I'm wrong and
                he's right kinda crap. Its not about who's smarter or who's wrong or right
                but about solving the problem.


                In any case. Whether it was clear or not is unimportant at this point.
                Janwillem got it from the start and even if my post was completely unclear
                then someone should have been asking "Why would Janwillem say that instead
                of what Toby said"?.

                Hell, maybe I did overreact but statements like

                "The answer was correct. It's the question we are having a problem with"

                just piss me off to no end ;/ Its like someone trying to tell me that wrong
                answers are right because its the question thats wrong. If I did that in a
                class on a test and then after the test went up to him and said "no, the
                answer is 1. Your question: "1+1="? is wrong because it should have been
                "1+0="". You think he would say "Hey, thats great; Your right!! You get an
                A+"? Even in a philosophy class that wouldn't work... even more so.
                Wouldn't work in a business either. Its just wrong and Geoff is trying to
                feed me that BS.

                Jon


                Comment

                • Jerry Stuckle

                  #23
                  Re: using echo but need something to execute php code

                  Jon Slaughter wrote:
                  >Maybe if you would have explained it this way in the start you would have
                  >gotten better answers. This is NOT the problem you started with!
                  >>
                  >
                  It is exactly the problem I started with. I might have not explained as well
                  but that is entirely different.
                  >
                  >As it is, I can think of a couple of ways to do it. But after seeing the
                  >way you treat people trying to help you, I'm not inclined to post them.
                  >>
                  >
                  Well, its your choice. I might have overreacted and then that was my fault.
                  Now that I look at my original post I can see how it doesn't explain it that
                  well. I thought it was clear at the time.. in any case you just have to look
                  at the line
                  >
                  "Is there any command that essentially executes the code and then echo's
                  it?"
                  >
                  you know, Janwillem had no problem with it and he was the first to post. So
                  it can't be all that unclear.
                  >
                  I just don't like people trying to dictate to me how I'm suppose to think or
                  what I am thinking about.
                  >
                  "The answer was correct. It's the question we are having a problem with"
                  >
                  Thats just total BS. Now maybe I did overreact. If so then I apologize.
                  But when I read that I read that Geoff is telling me that my question is
                  wrong. I'll be damned if questions are wrong. Questions are not
                  propositions. He could have just said "Hey, I don't understand what your
                  exactly trying to do." instead of trying to make seem like I'm wrong and
                  he's right kinda crap. Its not about who's smarter or who's wrong or right
                  but about solving the problem.
                  >
                  >
                  In any case. Whether it was clear or not is unimportant at this point.
                  Janwillem got it from the start and even if my post was completely unclear
                  then someone should have been asking "Why would Janwillem say that instead
                  of what Toby said"?.
                  >
                  Hell, maybe I did overreact but statements like
                  >
                  "The answer was correct. It's the question we are having a problem with"
                  >
                  just piss me off to no end ;/ Its like someone trying to tell me that wrong
                  answers are right because its the question thats wrong. If I did that in a
                  class on a test and then after the test went up to him and said "no, the
                  answer is 1. Your question: "1+1="? is wrong because it should have been
                  "1+0="". You think he would say "Hey, thats great; Your right!! You get an
                  A+"? Even in a philosophy class that wouldn't work... even more so.
                  Wouldn't work in a business either. Its just wrong and Geoff is trying to
                  feed me that BS.
                  >
                  Jon
                  >
                  >
                  Jon,

                  Well, get over it. He answered the question you asked. Then you told
                  him it wasn't the answer you wanted.

                  You asked if "Is there any command that essentially executes the code
                  and then echo's it?". include() does exactly that.

                  The fact is, you don't want to just execute and echo the code. Now you
                  tell us you want to modify results before it's output. That's a
                  different problem.

                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstucklex@attgl obal.net
                  =============== ===

                  Comment

                  • Jon Slaughter

                    #24
                    Re: using echo but need something to execute php code

                    Well, get over it. He answered the question you asked. Then you told him
                    it wasn't the answer you wanted.
                    >
                    No, thats the point. he didn't answer it. He answered the question he
                    thought I asked and then when I said it wasn't Geoff has to jump in and give
                    me some BS.
                    You asked if "Is there any command that essentially executes the code and
                    then echo's it?". include() does exactly that.
                    >
                    yeah, and if thats all you read of my post then obviously your going to post
                    the wrong thing. Maybe its not clear because you fail to read the full post?

                    How bout reading the full post? Is that to much to ask?

                    "essentiall y I am trying to include php/html files in one another but I need
                    to do some parsing on them first. I'd rather not do something like"

                    If that isn't clear then I don't know what is.
                    The fact is, you don't want to just execute and echo the code. Now you
                    tell us you want to modify results before it's output. That's a different
                    problem.
                    I said that. I'm not going to bother wasting energy quoting my original post
                    but if you bother to actually look at it then you'll see thats exactly what
                    I said. It might not have been clear but it was obviously clearn enough for
                    Janwillem.


                    Comment

                    • Geoff Berrow

                      #25
                      Re: using echo but need something to execute php code

                      Message-ID: <FV9Zh.18124$Kd 3.762@newssvr27 .news.prodigy.n etfrom Jon
                      Slaughter contained the following:
                      >No, thats the point. he didn't answer it. He answered the question he
                      >thought I asked and then when I said it wasn't Geoff has to jump in and give
                      >me some BS.
                      Frankly I wish I'd made a much more critical comment. Then at least I'd
                      feel I deserved this outpouring of angst.

                      Still if it relieves your tension feel free to continue acting like an
                      arse.

                      --
                      Geoff Berrow (put thecat out to email)
                      It's only Usenet, no one dies.
                      My opinions, not the committee's, mine.
                      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                      Comment

                      • Jerry Stuckle

                        #26
                        Re: using echo but need something to execute php code

                        Jon Slaughter wrote:
                        >Well, get over it. He answered the question you asked. Then you told him
                        >it wasn't the answer you wanted.
                        >>
                        >
                        No, thats the point. he didn't answer it. He answered the question he
                        thought I asked and then when I said it wasn't Geoff has to jump in and give
                        me some BS.
                        >
                        If that wasn't the question you asked, then you are not clear with your
                        question. IME Geoff is pretty knowledgeable and accurate in his response.
                        >You asked if "Is there any command that essentially executes the code and
                        >then echo's it?". include() does exactly that.
                        >>
                        >
                        yeah, and if thats all you read of my post then obviously your going to post
                        the wrong thing. Maybe its not clear because you fail to read the full post?
                        >
                        Or maybe it's not clear because you don't explain thoroughly?
                        How bout reading the full post? Is that to much to ask?
                        >
                        I did. And I came to the same conclusion Geoff did.
                        "essentiall y I am trying to include php/html files in one another but I need
                        to do some parsing on them first. I'd rather not do something like"
                        >
                        If that isn't clear then I don't know what is.
                        >
                        That's perfectly clear. As clear as mud.
                        >The fact is, you don't want to just execute and echo the code. Now you
                        >tell us you want to modify results before it's output. That's a different
                        >problem.
                        >
                        I said that. I'm not going to bother wasting energy quoting my original post
                        but if you bother to actually look at it then you'll see thats exactly what
                        I said. It might not have been clear but it was obviously clearn enough for
                        Janwillem.
                        >
                        >
                        And I'm not going to bother wasting my energy trying to answer someone
                        who 1) doesn't make his question clear, and 2) attacks people trying to
                        help him.

                        Even if I got paid for this (I don't), I've put in too many years to put
                        up with your BS.

                        --
                        =============== ===
                        Remove the "x" from my email address
                        Jerry Stuckle
                        JDS Computer Training Corp.
                        jstucklex@attgl obal.net
                        =============== ===

                        Comment

                        Working...