如何从我的php脚本向我的可执行文件发送参数?

I am building a website using php. I need to send a variable to a command line executable from the php site, run the executable, and then read the response.

I believe I am not sending the argument to the executable correctly.

My php code:

<?php
$a=escapeshellarg('6');
//set $c [lindex $argv 0];
$answer = shell_exec("D:/WebPages/Test/PHP_Test.exe $a");
echo $answer;
?>

My c# executable code

using System;

namespace PHP_Test
{
    class Hello
    {
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please enter a numeric argument.");
            }
            else
            {
                Console.WriteLine("Hello World!");

            }
        }
    }
}

As you can see, my executable is currently just set up to provide a response based on whether an argument was provided or not. When I don't send an argument from php, I get the correct response ("Please enter a numeric argument."). However, whenever I try to provide an argument, I am not getting any feedback at all, leading me to believe I am doing it incorrectly.

Any help is appreciated thank you.

With single quotes variable are not substituted with its values, you should use double quotes:

Edit: and add 2>&1 at the end of the command to get also the STDERR

$answer = shell_exec("D:\WebPages\PHP_Test.exe $a 2>&1");

I've found part of the answer for my issue. When including the path to the execution file, for some reason it wouldn't let me post any arguments. I put my execution file in the directory folder and called it without any path leading to the executable file and it then allowed arguments.