开发者

How to load php in between this ' ' in a php code?

I have a problem with my code!

My code-

<?php
$replace = 'ISO Burning Programs/Active@ ISO Burner 2.1.0.0/SPTDinst-v162-x86.exe';
$result = preg_replace_callback('/([^\/]*)(\/|$)/', function($matches){
    static $count = 0;
    $count++;
    return !empty($matches[1]) ? '
    <body onload="filetype_main(document.getElementById(\'file_type_'.$count.'\'));">
    <ul style="margin: 0px 0px 0px -20px;" type="none"><li id="file_type_li_'.$count.'">
    <form id="file_type_'.$count.'">
    <img alt="" name="file_img" class="file_img" id="file_img"/>
    <input name="file_type_ext" id="file_type_ext" name="file_type_ext" value="'.$matches[1].'" type="text" size="30"/>
    <font><?php echo "Cool";?>
    '
    .$matches[1].
    '
    </font></form></li></body>
    ' : '';
}, $replace);
echo "";
echo "Main Folder";
echo $result;
echo "";
?>

Now i want that my php code-

<?php echo "Cool"; ?>

To be properly shown like - Cool in my html page! But its not happening like that it doesn't show anything and when i see my source code using CHROME it shows the code in italics! Please help me!开发者_Python百科

Thanks Advance!


Why don't you just replace <?php echo "cool" ?> with "cool"?


In this case you can just replace <?php echo "Cool";?> to Cool.

But if you want to show a PHP variable value, you can just concatenate, just as you did with $count, for instance.


Change:

<?php echo "Cool";?>

to just

Cool


remove php tags near the cool

 <?php
    $replace = 'ISO Burning Programs/Active@ ISO Burner 2.1.0.0/SPTDinst-v162-x86.exe';
    $result = preg_replace_callback('/([^\/]*)(\/|$)/', function($matches){
        static $count = 0;
        $count++;
        return !empty($matches[1]) ? '
        <body onload="filetype_main(document.getElementById(\'file_type_'.$count.'\'));">
        <ul style="margin: 0px 0px 0px -20px;" type="none"><li id="file_type_li_'.$count.'">
        <form id="file_type_'.$count.'">
        <img alt="" name="file_img" class="file_img" id="file_img"/>
        <input name="file_type_ext" id="file_type_ext" name="file_type_ext" value="'.$matches[1].'" type="text" size="30"/>
        <font>'."Cool".

        .$matches[1].
        '
        </font></form></li></body>
        ' : '';
    }, $replace);
    echo "";
    echo "Main Folder";
    echo $result;
    echo "";
    ?>


HTML documents follow certain structure. Among other specs, there must be one <body></body> block. Your HTML includes three of these blocks so it's invalid.

Learn to use this tool:

  • http://validator.w3.org/#validate_by_input

Once your HTML triggers zero errors, it'll be easy to append Cool.

Update:

I misread your question. PHP code inside a PHP string will never run. Compare this:

<?php
$output = '<?php echo "Foo"?>';
?>

... with this:

<?php echo "Foo"?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜