php - New line not working -


description:

i have follwoing code:

        if(isset($risktriggerflag) && $risktriggerflag==1) // if risk_mitigator process reads , offer weight  maintained based on offer mentioned.         {             echo "risk weight: ".$risk_weight ."\n";             $randno = rand(1,100);              echo "random weight: ". $randno ."\n";             if($randno < intval(100 - $risk_weight))             {                 $flagthrowpostback = 1;             }         } 

as can see,i putting \n in text,but still message in getting printed in matter:

risk weight: 20 random weight: 20  

what doing wrong?

note:

i can't use br tag or nl2br() since total page php page, , don't want add html tags.

output on broswer coming this:

<html> <head></head> <body>multiple row risk weight: 20 random weight: 20 </body> </html> 

i think better way check whether php file executed cli or browser. in case browser use
else newline.

$newline = "<br />"; if (php_sapi === 'cli') {    // ...    $newline = "\n"; }  if(isset($risktriggerflag) && $risktriggerflag==1) // if risk_mitigator process reads , offer weight  maintained based on offer mentioned.     {         echo "risk weight: ".$risk_weight . $newline;         $randno = rand(1,100);          echo "random weight: ". $randno . $newline;         if($randno < intval(100 - $risk_weight))         {             $flagthrowpostback = 1;         }     } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -