改变里面的风格“if”声明 [英] changing the style inside "if" statement

查看:80
本文介绍了改变里面的风格“if”声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变只有一部分php的样式。这是我的代码;

I was trying to change the style of only a part of php. This is my codes;

if($fetch_array)
{
    $foto_destination = $fetch_array['foto'];
echo "<img src = '$foto_destination' height='150px' width='150px'>";
}
else
{



?>
<div style= "position:absolute; left:350px; top:70px;">
<?php
echo "<img src = 'images/avatar_default.png' height='150px' width='150px'>";
?>
</div>

但是,这个php部分在if里面。这就是为什么我无法改变它?如果if语句为真,我想在div标签内定义图像。我怎样才能做到这一点?我在哪里失踪?
谢谢

But, this php part is inside if. This is why i could not change it? I want to display the image where i define it inside the div tag if the statement of "if" is true. How can i do this? Where am i missing? Thanks

推荐答案

如果我理解正确,应该是:

If I understand you correctly, it should be:

<?php

if($fetch_array){
?>
<div style= "position:absolute; left:350px; top:70px;">
<?php
    $foto_destination = $fetch_array['foto'];
    print "  <img src = '$foto_destination' height='150px' width='150px'>";
}else{
?>
<div style= "position:absolute; left:350px; top:70px;">
  <img src = 'images/avatar_default.png' height='150px' width='150px'>
<?php
}
?>

</div>

它显示$ foto_destination,如果有的话。

It shows the $foto_destination, if there is one.

HTH

这篇关于改变里面的风格“if”声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆