| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2003-09-03 11:28 UTC] sniper@php.net
  [2004-03-08 17:17 UTC] mhmad3800 at al-islam dot com
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 12:00:01 2025 UTC | 
Description: ------------ Running the same script from the command line and in a browser generates different results. In the browser a cleaned up HTML string is returned (as expected) whereas on the CLI I get nothing.. string(0) Reproduce code: --------------- <?php $text = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body bgcolor="#FFFFFF" link="blue" vlink="purple" lang="EN-US"> <div class="Section1"> <h1>1. Some title</h1> <p><span lang="EN-GB">Some text </span></p> </div> </body> </html>'; $text = strip_tags($text, '<table><tr><th><td><a><ul><li><ol><p><h1><h2><h3><h4><h5><h6>'); var_dump($text); ?> Expected result: ---------------- string(83) " <h1>1. Some title</h1> <p>Some text </p> " This is printed when I run the code in a browsers. Looks ok to me. Actual result: -------------- string(0) "" this is what PHP CLI prints. Doing an echo of the unstripped $text works fine, it returns the HTML. After I run the strip_tags over it though $text becomes empty it seems.