How to use relative paths in exec command?

exec, php, relative-path

Solution

You can use `realpath` to turn relative path into an absolute one before calling `exec()`

$rel = 'something/program_name';
$abs = realpath($rel);
exec($abs);

Problem

How to run external program from PHP with `exec` command using relative paths? ``` <?php exec('program_name ......'); ?> ``` This works only if `program_name.exe` is in the same directory as the PHP script. For example `exec('something/program_name ......');` doesn't work if php script is not in the 'something' directory.

Original source