如何从PHP对象输出单行JavaScript?

My PHP code:

include "something.php"
$mysite = writeContent();

//footer.php
ob_start();
echo "<script...all my javascript here...</script>";
$object = ob_get_contents();
ob_end_clean();

$search = array("
","");
$replace = array("","");
$object = str_replace($search, $replace, $object);
echo $object;

then my JavaScript is malformed and doesn't work.

I know I can use gzip to increase the speed (thats not what I'm asking) but what I really want is to remove the extra space from the code.

查看全部
dongzhi6927
dongzhi6927
2011/06/15 19:20
  • php
  • javascript
  • object
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复