Coldfusion for PHP

I am converting an entire site from Coldfusion to PHP. So expect a lot of such questions. How to write this in PHP:

<cfif cgi.script_name contains "newsletter">

      

+3


source to share


3 answers


The second added value to strips is as follows:



    if (stripos ($ _ SERVER ['PHP_SELF'], substr ('newsletter', 0))) {

    // do something

    }
0


source


if(stripos($_SERVER['PHP_SELF'],"newsletter") > 0){

      



should do the same. Stripos, not strpos, because coldfusion is case insensitive, and a simple comparison like ceejayoz would be invalid since it would of course only match a specific file (which, however, might be desirable in many situations, but not the same as yours cfml).

+7


source


The closest equivalent would be something like:

if($_SERVER['PHP_SELF'] == '/newsletter.php') {
  // do something
}

      

There will not always be one-to-one equivalence of functions between CF and PHP, and as a result, there will often be more context than you provided.

+1


source







All Articles