php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25380 strip_tags works different on CLI and Apache
Submitted: 2003-09-03 07:02 UTC Modified: 2003-09-03 11:28 UTC
From: jeroen at terena dot nl Assigned:
Status: Closed Package: CGI/CLI related
PHP Version: 4.3.2 OS: Linux
Private report: No CVE-ID: None
 [2003-09-03 07:02 UTC] jeroen at terena dot nl
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. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-03 11:28 UTC] sniper@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 [2004-03-08 17:17 UTC] mhmad3800 at al-islam dot com
mhmad alhmode
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC