使用exec()和PHP运行命令

I am trying to run an openssl command through php which generally works fine but there is one particular command i am trying to run which doesn't work.

Here is the command run manually which works perfectly:

openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout keyfile.key -out requestfile.csr

For example, here is an openssl in PHP which DOES work:

exec('C:/xampp/apache/bin/openssl ecparam -out keyfile.key -name prime256v1 -genkey');

The same command through PHP does NOT work..

exec('C:/xampp/apache/bin/openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj \'/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com\' -keyout keyfile.key -out requestfile.csr');

I am thinking there is something wrong with the parts in double quotes "/C=" may not be getting interpreted properly. if I make similar openssl calls through php without the parts in "" the command executes fine.

Would like a knowledgeable php person to check if its being passed correct or not

Please don't suggest to me to use PHP's built in openssl library, i am well aware of them and I have all that working on a different project but I need to use exec() to create ECC keys which is not available in PHP's built in openssl library.

I don't think Windows cmd.exe allows you to use single quotes to quote an argument, you have to use double quotes.

exec('C:/xampp/apache/bin/openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout keyfile.key -out requestfile.csr');