当前位置: 动力学知识库 > 问答 > 编程问答 >

parsing - ob_get_clean returns empty in php

问题描述:

I have large amount of data as string which includes text and lots of images.

The string includes specials tags like the following as well as normal text + images.

{{ title }}

I have a function which check if that string contains any php tags ?> or <?php

The function is

 protected function parseTxt($text){

echo $text; //Gives me correct string

ob_start();

$result = eval('?>'.$text.'<?php ');

if ($result === false){

echo '<br />You have a syntax error.The snippet of text that contains

the error has been output below:<br />';

exit(str_replace(array('?>', '<?php '), '', $text));

}

return ob_get_clean();

}

I get the str as null.

I have php 5.5 and I have increased memory limit to 512

Please suggest as I am not having any alternative clue.Any help is highly appreciated.

网友答案:

Your code must be exiting before reaching ob_get_clean() . Also, dont use eval. Just dont. Why dont you just echo $text ?

P.S.

eval is evil

分享给朋友:
您可能感兴趣的文章:
随机阅读: