如何禁用bash在printf函数的文件的开头和结尾添加额外的引用?

I am running this line in various server with various configuration:

<?php shell_exec("printf \"Hello World\" > result.txt"); 

In some servers the result.txt will have:

Hello World

But in others, I get:

"Hello World"

How can I prevent bash to add the double quote?

Just don't wrap it in quotes? Escape the space instead.

<?php shell_exec("printf Hello\ World > result.txt"); 

We can further simplify the command so that no quotes are needed:

<?php shell_exec("echo Hello World > result.txt");