Why does PHP print a percent sign when my script is done?

This is from zsh.

Your output doesn't end with a line break. Bash would start the PS1 right after your output, zsh prints a (colored) % and insert a line break itself. You can prevent it by adding a line break yourself

php -r 'echo "Hello World\n";'

Note: I switched " and ', in php '\n' would print it as is but "\n" means line break.


Adding a line to echo PHP_EOL in the end also helps.

echo PHP_EOL;

Example PHP code

Related output


Add this line to .zshrc :

PROMPT_EOL_MARK=''

It's work for me.

For detail explanation you can go here: https://superuser.com/a/645612