尝试在 PHP 回声中间使用行内样式

T.C*_*T.C -1 css php

无论如何我可以在 PHP echo 语句中获得内嵌样式。我想设置图像的高度和宽度,因为当我尝试在height外部应用和 `width 时,它没有区别,因为图像在样式设置之前加载。

我已经尝试过这个,但似乎没有任何区别......

<p><b>Profile Picture: </b>
<?php 
    $picture = $row['imagePath'];
        if (empty($picture)){
            echo "<img src='profiles/no-image.png' 'width=500' 'height=600' >";
        } else {
        echo "<img src='".$row['imagePath']."' 'width=500' 'height=600' >";    
        };
?></p>
Run Code Online (Sandbox Code Playgroud)

rx2*_*347 5

这不起作用,因为您没有正确设置引号。

这应该可以解决问题:

echo "<img src='profiles/no-image.png' width='500' height='600' >";
Run Code Online (Sandbox Code Playgroud)

您可以以相同的方式应用样式:

echo "<img src='profiles/no-image.png' style='width:500px;height:600px;'>";
Run Code Online (Sandbox Code Playgroud)