#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Coldfusion to PHP Question


    I'm trying to turn some Coldfusion code into PHP and can't quite get the handle on it. Any help? Thanks in advance!

    <cfif find("#siteurl#",cgi.script_name) or find("#siteurl#",cgi.script_name) or find("#siteurl#index.cfm",cgi.script_name)><li class="current"><a class="topnavtext" href="#siteurl#">Home</a></li><cfelse> <li><a class="topnavtext" href="#siteurl#">Home</a></li></cfif>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    Here's the basic start to your goal, if you haven't this already. The only thing needing defining is your if(), but I do not know off-hand what or how Coldfusion's find() function works. What is this checking?
    PHP Code:
    <?php
      
    if() {
        echo 
    '<li class="current"><a class="topnavtext" href="#siteurl#">Home</a></li>';
      } else {
        echo 
    '<li><a class="topnavtext" href="#siteurl#">Home</a></li>';
      }
    ?>
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Coldfusion to PHP Reply


    Originally Posted by Triple_Nothing
    Here's the basic start to your goal, if you haven't this already. The only thing needing defining is your if(), but I do not know off-hand what or how Coldfusion's find() function works. What is this checking?
    PHP Code:
    <?php
      
    if() {
        echo 
    '<li class="current"><a class="topnavtext" href="#siteurl#">Home</a></li>';
      } else {
        echo 
    '<li><a class="topnavtext" href="#siteurl#">Home</a></li>';
      }
    ?>
    Thanks for your reply. It's looking for the string "tips" or "tip" in the query string. I think that the equivalent would maybe be $_SERVER['QUERY_STRING']? Not sure how to setup the "if" logic using this. Would this work?

    Code:
    if (strstr($_SERVER['QUERY_STRING'], "tips")) || if (strstr($_SERVER['QUERY_STRING'], "tip"))
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    Then all your would need to do is search for the 'tip' since 'tip' is in 'tips', so below should be enough. Do note that this will also be TRUE if it finds the word 'multiplying' since it contains the word 'tip' within. Will there be risks for such? Or will the haystacks be predefined items of some sort?

    PHP Code:
    if(str($haystack$needle)) { 
    So in your case, prolly...
    PHP Code:
    if(str($_SERVER['QUERY_STRING'], 'tip')) { 
    Last edited by Triple_Nothing; October 17th, 2013 at 11:15 AM.
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him

IMN logo majestic logo threadwatch logo seochat tools logo