有人可以帮助我解决这个问题。我试图回声输入与isset作为值在PHP中,但我遇到困难与逗号。PHP中的回声输入
echo '<td><input class="text" type="text" id="txtLogin" name="txtLogin" value="<?= isset($_POST['"txtLogin"']) ? htmlspecialchars($_POST['"txtLogin"']) : '' ></td>';
谢谢!
有人可以帮助我解决这个问题。我试图回声输入与isset作为值在PHP中,但我遇到困难与逗号。PHP中的回声输入
echo '<td><input class="text" type="text" id="txtLogin" name="txtLogin" value="<?= isset($_POST['"txtLogin"']) ? htmlspecialchars($_POST['"txtLogin"']) : '' ></td>';
谢谢!
试试这个
echo '<td><input class="text" type="text" id="txtLogin" name="txtLogin" value="'.isset($_POST['"txtLogin"']) ? htmlspecialchars($_POST['"txtLogin"']) : "".'"></td>';
您只需连接字符串像这样的表述:
echo '<td><input class="text" type="text" id="txtLogin" name="txtLogin" value="' . (isset($_POST['"txtLogin"']) ? htmlspecialchars($_POST['"txtLogin"']) : '') . '"></td>';
谢谢,它的工作原理! – user2260906 2013-04-09 09:22:33
@Manuel。应该有一个结束双引号值 – Sabari 2013-04-09 10:02:21
@Sabari你是对的,谢谢。固定的 – Manuel 2013-04-09 10:10:36
你可以试试这个。
<?php
echo '<td><input class="text" type="text" id="txtLogin" name="txtLogin" value="' . isset($_POST['txtLogin']) ? htmlspecialchars($_POST['txtLogin']) : '' . '></td>';
?>
您在双引号后缺少单引号 – Sabari 2013-04-09 09:14:42
一个清洁的解决方案将是:
$txtLogin = isset($_POST['"txtLogin"']) ? htmlspecialchars($_POST['"txtLogin"']) : "";
echo '<td><input class="text" type="text" id="txtLogin" name="txtLogin" value="'. $txtLogin .'"></td>';
这是一件好事,而不是添加引号内
条件语句您不必再为PHP脚本开始标记。 'isset()'之前的<?='是错误的。 '='符号表示'echo',现在你有:'echo“一些字符串<?php echo'另一个字符串'”等等......这是错误的。使用点分隔字符串和PHP代码,例如'回声'字符串'。 some_php_stuff()。 '另一个字符串';' – enenen 2013-04-09 09:11:41