concat echo语句和html代码中的语法错误

时间:2022-11-22 22:53:05

Please help me to understand syntax of concat following

请帮我理解concat的语法

i want following code inside echo to understand concate

我想在echo中使用以下代码来理解concate

1--> <div class="alert echo $_REQUEST['error_id'];?>"\>

1 - >

”\>

I try following code but getting syntax error that there is two echo..

我尝试下面的代码,但得到语法错误,有两个回声..

2--> echo "<div class=\"alert" . echo $_REQUEST['error_id']; . "\">";

2 - > echo“

”;

where mistake is that i cant get it... and i want two answer both using single quote and double quote

错误是我无法得到它...我想要两个回答使用单引号和双引号

EDIT

Thank @Rizier123 now it working but css is not working as i have apply in calss="alert"

感谢@ Rizier123现在它正在工作,但css无法正常工作,因为我申请了calss =“alert”

while using following code its working fine <div class="alert echo $_REQUEST['error_id'];?>"\>

使用以下代码时,其工作正常

”\>

concat echo语句和html代码中的语法错误

But after applying your code its not working..only text appear but background color is not comming nad boarder is also dissappear as below

但在应用你的代码后,它不工作..只有文字出现,但背景颜色不会出现nad寄宿生也消失如下

concat echo语句和html代码中的语法错误

class name is alert shows the status of login..

类名是alert,显示登录状态..

EDIT

Thanks again i just forget to put space after class name..

再次感谢我忘了把课后的名字放进去。

3 个解决方案

#1


3  

You don't need to write echo and ; again!

你不需要写回声和;再次!

So this should work:

所以这应该工作:

//echo with double quotes
echo "<div class=\"alert" . $_REQUEST['error_id'] . "\">";        

//echo with single quotes
echo '<div class="alert' . $_REQUEST['error_id'] . '">';       

Maybe you need to add a space if your class name includes spaces!(..."alert "...)

如果您的班级名称包含空格,也许您需要添加一个空格!(...“alert”...)

#2


2  

try this

echo '<div class=\"alert"' .  $_REQUEST['error_id'] . '">';

#3


2  

You can do either 2 ways

你可以做两种方式

1. PHP in HTML

1. HTML格式的PHP

<div class="alert<?php echo $_REQUEST['error_id'];?>">

2. HTML in PHP

2. PHP中的HTML

echo "<div class='alert". $_REQUEST['error_id'] ."'>";

Or you can also do like

或者你也可以这样做

echo "<div class=\"alert". $_REQUEST['error_id'] ."\">";

#1


3  

You don't need to write echo and ; again!

你不需要写回声和;再次!

So this should work:

所以这应该工作:

//echo with double quotes
echo "<div class=\"alert" . $_REQUEST['error_id'] . "\">";        

//echo with single quotes
echo '<div class="alert' . $_REQUEST['error_id'] . '">';       

Maybe you need to add a space if your class name includes spaces!(..."alert "...)

如果您的班级名称包含空格,也许您需要添加一个空格!(...“alert”...)

#2


2  

try this

echo '<div class=\"alert"' .  $_REQUEST['error_id'] . '">';

#3


2  

You can do either 2 ways

你可以做两种方式

1. PHP in HTML

1. HTML格式的PHP

<div class="alert<?php echo $_REQUEST['error_id'];?>">

2. HTML in PHP

2. PHP中的HTML

echo "<div class='alert". $_REQUEST['error_id'] ."'>";

Or you can also do like

或者你也可以这样做

echo "<div class=\"alert". $_REQUEST['error_id'] ."\">";