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

    Join Date
    Dec 2012
    Posts
    12
    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
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,356
    Rep Power
    24
    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 that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    12
    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
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,356
    Rep Power
    24
    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 that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.

IMN logo majestic logo threadwatch logo seochat tools logo