[lang-ref] 実行時のコマンド名(パス)を取得 ( php )

<?php
public function testGetExecutedCommandPath(): void
{
	// $argv[0]

	/* examples/get_executed_command_path.php
		<?php
			function printArgv0() {
				global $argv;
				echo($argv[0]);
			}
			if (realpath($argv[0]) === __FILE__) {
				printArgv0();
			}
	*/

	/* examples/get_executed_command_path_call.php
		<?php
			require_once('get_executed_command_path.php');
			printArgv0();
	*/

	$out = shell_exec('php examples/get_executed_command_path.php');
	$this->assertSame('examples/get_executed_command_path.php', $out);

	$out = shell_exec('php examples/get_executed_command_path_call.php');
	$this->assertSame('examples/get_executed_command_path_call.php', $out);
}