"Late" variable substitution

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

    "Late" variable substitution

    Hi...

    I want to know if this is possible.

    I have a database with an attribute which has in it a SQL statement,
    e.g.

    select blah from table where key = $x

    In a PHP function, I read in the above string into $v.
    In that routine, $x is defined.

    However, if I print out the string I get the original string, with $x
    not being substituted.

    What I want to happen is the local value of $x to get substituted into
    $v.

    Is this possible? If so, how do you do it?

    TIA,
    Joe

  • Gordon Burditt

    #2
    Re: "Late&quot ; variable substitution

    >I want to know if this is possible.
    >
    >I have a database with an attribute which has in it a SQL statement,
    >e.g.
    >
    >select blah from table where key = $x
    >
    >In a PHP function, I read in the above string into $v.
    >In that routine, $x is defined.
    >
    >However, if I print out the string I get the original string, with $x
    >not being substituted.
    Show code. In particular:

    echo 'key = $x';
    and echo "key = $x';

    are *NOT* the same thing.
    >What I want to happen is the local value of $x to get substituted into
    >$v.
    Um, what does this mean?

    Do you mean you have something like:
    $v = 'Up your $x with a $x';
    (note: no substitution is done here)

    and later you do:

    $x = 'Hose';
    echo $v;

    and you want it to print
    Up your Hose with a Hose
    ?
    >Is this possible? If so, how do you do it?
    It might be possible with 'eval', if I have interpreted the
    question correctly.

    Comment

    • JoeT

      #3
      Re: "Late&quot ; variable substitution

      That did the trick!

      Thanks much!

      Joe


      Gordon Burditt wrote:
      I want to know if this is possible.

      I have a database with an attribute which has in it a SQL statement,
      e.g.

      select blah from table where key = $x

      In a PHP function, I read in the above string into $v.
      In that routine, $x is defined.

      However, if I print out the string I get the original string, with $x
      not being substituted.
      >
      Show code. In particular:
      >
      echo 'key = $x';
      and echo "key = $x';
      >
      are *NOT* the same thing.
      >
      What I want to happen is the local value of $x to get substituted into
      $v.
      >
      Um, what does this mean?
      >
      Do you mean you have something like:
      $v = 'Up your $x with a $x';
      (note: no substitution is done here)
      >
      and later you do:
      >
      $x = 'Hose';
      echo $v;
      >
      and you want it to print
      Up your Hose with a Hose
      ?
      Is this possible? If so, how do you do it?
      >
      It might be possible with 'eval', if I have interpreted the
      question correctly.

      Comment

      Working...