Announcement

Collapse
No announcement yet.

Interesting PHP checking variables containing a hyphen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Interesting PHP checking variables containing a hyphen

    Hi,

    This is more of a heads-up than a request for help.

    Basically, I'm showing some graphical content (other products) based on the Section currently being shown.

    I've got a block containing this:

    PHP Code:
        $currentsection "<actinic:variable name="SectionName" />"
    And then a bit lower down it does this:

    PHP Code:
    if     ($currentsection == "Birthdays") {
           [
    Go and do something]

    I do this quite merrily and all is working well. However, there is one section called "Ages 10 - 80". And for everything I've tried it will not pass through this "IF" successfully:

    PHP Code:
    if     ($currentsection == "Ages 10 - 80") {
           [
    Go and do something]

    However, if I change the name of the section to "Ages 10 to 80" (i.e. replace the hyphen with the word 'to' and change the IF statement accordingly) then it works fine. I wonder if it is applying the calculation "10 - 80" or something? (I even checked if $currentsection == "Ages -70"!).

    #2
    The problem isn't in the IF, it's in the Actinic variable.

    Use:
    Code:
    $currentsection = '<actinic:variable name="SectionName" encoding="perl" selectable="false" />';
    Note that the single quotes are essential too.

    As you had it, Actinic would be generating something like Ages 10 &#nn 80 as it escapes all special characters before outputting them to the HTML. I.e. so that Ages < 10 would not inadvertantly start an HTML tag.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Ahhhh.... thank you! I'm enlightened

      Comment


        #4
        Have changed it following your advice. Many thanks!

        Comment

        Working...
        X