Weirdest PHP problem of all time?!

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

    Weirdest PHP problem of all time?!

    [PHP]
    print_r("2hasRe sult = $hasResult<P>") ;

    /*---------------------------------------------------------------------------------------------------------------------------------------------------------
    Block to determine metadata. If you are coming from DownloadView
    or RemoveView you will have to have
    a database instance to generate proper metadata for display,
    however, coming from CreateView or ResizeView you
    will not have any database instance, so metadata will be limited
    and derived from the image source itself.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------*/
    $imageURL = ($album) ? "$imageURLP ath/$album" : $imageURLPath;

    print_r("3hasRe sult = $hasResult<P>") ;

    [/PHP]

    At no time are any of the variables even remotely related to one
    another, but watch this:

    2hasResult =

    3hasResult = /catalog/images/awards_2004
    For some wacko reason $hasResult = $imageURL! I have never even used
    reference pointers for any of these variables, how is that possible?

    Thanx
    Phil
  • Westcoast Sheri

    #2
    Re: Weirdest PHP problem of all time?!

    Phil Powell wrote:
    [color=blue]
    > [PHP]
    > print_r("2hasRe sult = $hasResult<P>") ;
    >
    > /*---------------------------------------------------------------------------------------------------------------------------------------------------------
    > Block to determine metadata. If you are coming from DownloadView
    > or RemoveView you will have to have
    > a database instance to generate proper metadata for display,
    > however, coming from CreateView or ResizeView you
    > will not have any database instance, so metadata will be limited
    > and derived from the image source itself.
    > -----------------------------------------------------------------------------------------------------------------------------------------------------------*/
    > $imageURL = ($album) ? "$imageURLP ath/$album" : $imageURLPath;
    >
    > print_r("3hasRe sult = $hasResult<P>") ;
    >
    > [/PHP]
    >
    > At no time are any of the variables even remotely related to one
    > another, but watch this:
    >
    >
    > 2hasResult =
    >
    > 3hasResult = /catalog/images/awards_2004
    >
    >
    > For some wacko reason $hasResult = $imageURL! I have never even used
    > reference pointers for any of these variables, how is that possible?
    >
    > Thanx
    > Phil[/color]

    I am a PHP newbie.... but if I were trying to fix this, I might change this:
    $imageURL = ($album)
    ....to this:
    ($imageURL == $album)





    Comment

    • Michael Fesser

      #3
      Re: Weirdest PHP problem of all time?!

      .oO(Westcoast Sheri)
      [color=blue]
      >I am a PHP newbie.... but if I were trying to fix this, I might change this:
      >$imageURL = ($album)
      >...to this:
      >($imageURL == $album)[/color]

      Nope, it wasn't a comparison, it was an assignment using a ternary
      operator.

      The posted code looks correct, I guess the problem is somewhere in the
      parts that were not posted.

      Micha

      Comment

      • Ian.H

        #4
        Re: Weirdest PHP problem of all time?!

        On Sat, 24 Jul 2004 13:38:03 +0000, Westcoast Sheri wrote:
        [color=blue]
        > I am a PHP newbie.... but if I were trying to fix this, I might change this:
        > $imageURL = ($album)
        > ...to this:
        > ($imageURL == $album)[/color]


        $imageURL = ($album) ? "$imageURLP ath/$album" : $imageURLPath;


        is the same as writing:


        if ($album) {
        $imageURL = "$imageURLP ath/$album";
        } else {
        $imageURL = $imageURLPath;
        }


        and outlines perhaps more clearly being new, why it's as assignment rather
        than a comparison.

        Welcome to PHP =)



        Regards,

        Ian

        --
        Ian.H
        digiServ Network
        London, UK


        Comment

        • Geoff Berrow

          #5
          Re: Weirdest PHP problem of all time?!

          I noticed that Message-ID:
          <pan.2004.07.24 .23.22.52.32800 0@bubbleboy.dig iserv.net> from Ian.H
          contained the following:
          [color=blue]
          > $imageURL = ($album) ? "$imageURLP ath/$album" : $imageURLPath;
          >
          >
          >is the same as writing:
          >
          >
          > if ($album) {
          > $imageURL = "$imageURLP ath/$album";
          > } else {
          > $imageURL = $imageURLPath;
          > }
          >[/color]


          Wouldn't both generate a notice? Does it matter?
          --
          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

          Working...