我有一个看起来像这样的字符串:
<center>
<div style="margin-top: 10px; margin-bottom: 10px; font-size: 20px; color: #000; font-weight: bold;">
<?php echo strlen(file_get_contents('test.txt')); ?> Applications Sent
</div>
</center>
Run Code Online (Sandbox Code Playgroud)
但是,我想用if语句来回应这个问题.例如:
if ($test == '') {
echo '<center><div style="margin-top: 10px; margin-bottom: 10px; font-size: 20px; color: #000; font-weight: bold;"><?php echo strlen(file_get_contents("test.txt")); ?> Applications Sent</div></center>';
}
Run Code Online (Sandbox Code Playgroud)
问题是这不起作用,因为原始字符串中已经有回声.我怎么能绕过这个?
为了实现这一点,你应该连接你的字符串.在这种情况下,你有一个函数周围的两个字符串 - 但该函数返回一个字符串,所以将它们连接在一起是完全有效的.
if ($test == '') {
echo '<center><div style="margin-top: 10px; margin-bottom: 10px; font-size: 20px; color: #000; font-weight: bold;">' . strlen(file_get_contents("test.txt")) . ' Applications Sent</div></center>';
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1220 次 |
| 最近记录: |