解析错误:语法错误,第7行意外的T_CONSTANT_ENCAPSED_STRING - [英]Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on line 7 - 本文翻译自  user2986615  查看原文  2013-11-13  254    php/

时间:2021-08-20 22:46:42

I am getting error on line 7 syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

我在第7行语法错误中得到了错误,意外的T_CONSTANT_ENCAPSED_STRING

<div id='login_form_container'>
    <div class='dInlineB' align="left">
        <label class='login_form_label' for='email'>Email:</label>
        <input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='']."'" : "");?>
    </div>
        <div class='dInlineB' align="left">
        <label class='login_form_label' for='password'>Password:</label>
        <input type='password' name='password' id='password' tabindex="2" class='login_form_input' />
    </div>
    <div align="left">
        <div class='login_form_spacer'>&nbsp;</div>
        <div class='dInline fs11'>
            <label for='login_form_stay'>
                <input type='checkbox' name='stayLogged' tabindex="3" checked='checked' value='1' id='login_form_stay' />

                Keep me logged in
            </label>
        </div>

4 个解决方案

#1


0  

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='']."'" : "");?>

is malformed, please see the following correct line:

是畸形,请见以下正确的线:

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='".$_POST['email']."'" : "");?>>

Code highlighting here on SO already shows where your error is at. What you missed was adding the value from $_POST to your input. In order to add PHP variable in a string you have to append the PHP like this: "this is a string" . $variable . " continued string" or with single quotes: 'this is a string' . $variable . ' continued string'.

这里的代码高亮显示了错误所在。您所遗漏的是将$_POST的值添加到输入中。为了在字符串中添加PHP变量,您必须这样附加PHP:“这是一个字符串”。美元的变量。“连续字符串”或单引号:“这是一个字符串”。美元的变量。“继续弦”。

Using double or single quotes depends on whether you want to be able to use variables inline as well, which works on double, but not on single quotes: "this $variable works inline" . 'but the $variable doesn\'t work here'. For more info about the double/single quotes: What is the difference between single-quoted and double-quoted strings in PHP?

使用双引号或单引号取决于您是否也希望使用内联变量,这适用于双引号,但不适用于单引号:“这个$变量是内联的”。“但是$变量在这里不起作用”。关于双引号/单引号的更多信息:PHP中单引号和双引号的区别是什么?

#2


0  

Rewrite line this like

重写这行像

  <input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='".$_POST['email']."'" : "");?>>

#3


0  

You can replace :

你可以替换:

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='']."'" : "");?>

with :

:

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" >

#4


0  

replace this line by

把这条线换成

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) /? " value='']."'" : "");?>

#1


0  

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='']."'" : "");?>

is malformed, please see the following correct line:

是畸形,请见以下正确的线:

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='".$_POST['email']."'" : "");?>>

Code highlighting here on SO already shows where your error is at. What you missed was adding the value from $_POST to your input. In order to add PHP variable in a string you have to append the PHP like this: "this is a string" . $variable . " continued string" or with single quotes: 'this is a string' . $variable . ' continued string'.

这里的代码高亮显示了错误所在。您所遗漏的是将$_POST的值添加到输入中。为了在字符串中添加PHP变量,您必须这样附加PHP:“这是一个字符串”。美元的变量。“连续字符串”或单引号:“这是一个字符串”。美元的变量。“继续弦”。

Using double or single quotes depends on whether you want to be able to use variables inline as well, which works on double, but not on single quotes: "this $variable works inline" . 'but the $variable doesn\'t work here'. For more info about the double/single quotes: What is the difference between single-quoted and double-quoted strings in PHP?

使用双引号或单引号取决于您是否也希望使用内联变量,这适用于双引号,但不适用于单引号:“这个$变量是内联的”。“但是$变量在这里不起作用”。关于双引号/单引号的更多信息:PHP中单引号和双引号的区别是什么?

#2


0  

Rewrite line this like

重写这行像

  <input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='".$_POST['email']."'" : "");?>>

#3


0  

You can replace :

你可以替换:

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) ? " value='']."'" : "");?>

with :

:

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" >

#4


0  

replace this line by

把这条线换成

<input type='email' name='email' id='email' tabindex="1" class='login_form_input'<?=(isset($_POST['email']) /? " value='']."'" : "");?>