Home >Backend Development >PHP Tutorial > 这段代码用PHP基准格式写应该是怎样的

这段代码用PHP基准格式写应该是怎样的

WBOY
WBOYOriginal
2016-06-13 13:19:15841browse

这段代码用PHP标准格式写应该是怎样的
在公用PHP文件里做了个判断,需要混排PHP和HTML,自己不会写,麻烦大家帮忙改写一下这段,用PHP的标准写法是怎样的:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php if $id=1
{ 
    echo "<title> $row['p_name']; - 欢迎光临!
       <meta name="keywords" content="$row['p_name'];,关键字测试">
           <meta name="description" content="$row['p_name'];,描述测试"> 
          ";
}
else
{
     echo "<title>Welcome</title>
       <meta name="keywords" content="关键字测试">
           <meta name="description" content="描述测试"> 
          ";
}
?>



谢谢!!!

------解决方案--------------------
还是这样吧:
PHP code
<?php if( $id === 1 )
{ 
    echo "html
       <title> {$row['p_name']} - 欢迎光临!
       <meta name='\"keywords\"' content="\"{$row['p_name']},关键字测试\"">
       <meta name='\"description\"' content="\"{$row['p_name']},描述测试\""> ";
}
else
{
     echo "
       <title>Welcome</title>
       <meta name='\"keywords\"' content='\"关键字测试\"'>
       <meta name='\"description\"' content='\"描述测试\"'>";
}
?>
<br><font color="#e78608">------解决方案--------------------</font><br><?php <br />$title = ''; $keywords = ''; $description = '';<br>if($id==1){<br>	$title = $row['p_name'];<br>	$keywords = $row['p_name'];<br>	$description = $row['p_name'];<br>}?><br><title><?php echo $title;?></title><br><meta name="keywords" content="<?php echo $keywords;?>,关键字测试"><br><meta name="description" content="<?php echo $description;?>,关键字测试">
<br><font color="#e78608">------解决方案--------------------</font><br>- -  傻了,上面第一行应该是$title = 'Welcome' <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn