Ouick php question

Discussion in 'Programming' started by ging999, Jan 17, 2010.

  1. #1
    Would this work so the myString is ramdomly implimented

    <?
    $myString = "<?
    if(!$_SERVER[‘HTTP_REFERER’]){
    header("HTTP/1.0 404 Not Found");
    } else {
    header("Location: http://??????????????????.com/BDHDHDHDJ/");
    }
    ?>";


    $random_number = rand(1,4);
    if($random_number == 1){
    echo $myString;
    }
    ?>


    Thanks
     
    ging999, Jan 17, 2010 IP
  2. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    since it is string, you need to replace " with \"

    
    <?
    $myString = "<?
    if(!$_SERVER[‘HTTP_REFERER’]){
    header(\"HTTP/1.0 404 Not Found\");
    } else {
    header(\"Location: http://??????????????????.com/BDHDHDHDJ/\");
    }
    ?>";
    
    $random_number = rand(1,4);
    if($random_number == 1){
    	echo $myString;
    }
    ?>
    
    PHP:
     
    NeoCambell, Jan 17, 2010 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Why would you echo plain text code? What purpose does that serve? Why not just use the actual php code in the if ($random_number == 1) section?
     
    premiumscripts, Jan 18, 2010 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    yeah, I also agree with premiumscripts. What sense does it make to echo a code in plain text? Use it direct, and if at all want execute it other way round, why not eval it?
     
    mastermunj, Jan 18, 2010 IP