In Php, executing a Linux shell command is as simple as this:
$var = shell_exec("ls -l ~"); // execute command to view home directory
echo $var; // shows the output of the ls -l ~ command
It should work the same with ftp commands as long as apache has permissions to do what you want on the server (Php runs as the Apache user in the web browser).
If you run the Php script on the server directly, then you can have it run as whatever user you want (su to the user you want, and execute the Php script).