Hi guys,
Without explaining why because I want to get to the point quickly, I am having trouble exicuting a PHP command inside a PHP string. I'll explain what i mean:
I have a BB-code script which has a
string where you can enter some PHP and it will do what you say here. The script reads like this:
<?php
function BBcode($string) {
if(!empty($string)) {
//string not empty
$search = array (
//BBcode => //replacement
'(.?*)',
'[include](.?*)[/include]',
'
'
);
$replace = array (
'<strong>\1</strong>',
"include('\1')",
"<?php".'\1'. "?>"
);
$new_string = preg_replace($search,$replace,$string);
return $new_string;
} else {
return false;
}
?>
then the output string reads as:
<?php echo BBcode($my_page_content); ?>
other BBcode will go fine here, but if i use the [include] or
Without explaining why because I want to get to the point quickly, I am having trouble exicuting a PHP command inside a PHP string. I'll explain what i mean:
I have a BB-code script which has a
PHP:
<code here>
<?php
function BBcode($string) {
if(!empty($string)) {
//string not empty
$search = array (
//BBcode => //replacement
'(.?*)',
'[include](.?*)[/include]',
'
PHP:
(.?*)
);
$replace = array (
'<strong>\1</strong>',
"include('\1')",
"<?php".'\1'. "?>"
);
$new_string = preg_replace($search,$replace,$string);
return $new_string;
} else {
return false;
}
?>
then the output string reads as:
<?php echo BBcode($my_page_content); ?>
other BBcode will go fine here, but if i use the [include] or
PHP:
it don't do anything.
(i have ignored all escaping to cut down the size of the script for yahoo answers)
any ideas how i would do this? I hope i have explained it ok...was having trouble explaining it in text.
thanks in advance =)