如何用php5运行sudo终端命令?

Under a controlled environment, I will try to execute some calls to shell, some of such commands will include sudo privileges.

I tried this php code line:

$out = shell_exec('sudo -u root -S ls < /home/user/.y/.qqz');

Where at last .qqz is a file containing actual password.

However apache log shows this output:

[sudo] password for www-data:

Like the password file is not being passed to the command stdi?

I already made www-data part of the sudo group. How can I get my objective done?