语法错误,意外'<'使用eval和base64

时间:2014-04-04 10:34:26

标签: php encoding base64 eval

我正在尝试编码一个简单的代码,但我收到了这个错误:

Parse error: syntax error, unexpected '<' in C:\wamp\www\test.php(2) : eval()'d code on line 1

这是代码:

<form method="POST" action="">
Enter your command: <input type='text' name='cmd'> <input type='submit' name='execute'       value='Execute'>
</form>


echo $_POST['cmd'];

这是带有eval的base64_encode:

<?
eval(base64_decode('PGZvcm0gbWV0aG9kPSJQT1NUIiBhY3Rpb249IiI+CkVudGVyIHlvdXIgY29tbWFuZDogPGlu     cHV0IHR5cGU9J3RleHQnIG5hbWU9J2NtZCc+IDxpbnB1dCB0eXBlPSdzdWJtaXQnIG5hbWU9J2V4ZWN1dGUnIHZhbHVl     PSdFeGVjdXRlJz4KPC9mb3JtPgoKCmVjaG8gJF9QT1NUWydjbWQnXTsK'));
?>

2 个答案:

答案 0 :(得分:0)

那是因为你试图评估非PHP代码(html格式)

答案 1 :(得分:0)

您忘记了代码周围的PHP代码:

<?php

    // Any PHP code as needed

?>
    <form method="POST" action="">
    Enter your command: <input type='text' name='cmd'> <input type='submit' name='execute'       value='Execute'>
    </form>

<?php

    echo $_POST['cmd'];
?>