简体   繁体   English

在PHP中使用echo时出错

[英]Error With Using echo in PHP

When i use echo command in my code to print something to the screen it will add % character to the last of word ! 当我在代码中使用echo命令在屏幕上打印某些内容时,它将在单词的最后添加%字符!

but i face this problem only when i run the PHP application using the Linux terminal using the command php script.php 但是我仅在使用命令php script.php在Linux终端上运行PHP应用程序时才遇到此问题

The code is 该代码是

<?php
echo "Please Type The Hash : ";
$str = trim(fgets(STDIN,1024));
echo $str;
?>

Some shell interpreters (for example ZSH) adds "%" and newline at end of subprocess output to distinguish between output of process and input prompt of shell. 一些shell解释器(例如ZSH)在子进程输出的末尾添加“%”和换行符,以区分进程的输出和shell的输入提示。

Add a newline to your ouput: 在您的输出中添加换行符:

echo $str, "\n";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM