Hi there,
I have a couple of questions .
1. the html pages and images are stored in a directory and am calling the pages from a template (php) outside that directory.
so use the readfile() to get the page in dir into the template.
But unable to view the images in the dir page. Any suggestions? Is there any other function in php that would help
code in template.php
chdir("$dir");
readfile("index.html");
$dir contains images and index.html
no images seen in template.php that called index.html
2. How to execute a program or script from php.
say, need to run xmms from a button click.
Isaac,
India
unable to view images
Moderator: General Moderators
First:
Say your PHP script is in /dir/ and your files are in /dir/asdf/
If you do this, your index.html file will still have to access the images through <img src="asdf/1.gif"> and not <img src="1.gif"> This is because of the way the directory structure works with the HTML.
Second:
You can use the exec() function to do that, here's the PHP manual entry for it.
Say your PHP script is in /dir/ and your files are in /dir/asdf/
If you do this, your index.html file will still have to access the images through <img src="asdf/1.gif"> and not <img src="1.gif"> This is because of the way the directory structure works with the HTML.
Second:
You can use the exec() function to do that, here's the PHP manual entry for it.
string exec ( string command [, array output [, int return_var]])
exec() executes the given command, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.
If the output argument is present, then the specified array will be filled with every line of output from the command. Line endings, such as \n, are not included in this array. Note that if the array already contains some elements, exec() will append to the end of the array. If you do not want the function to append elements, call unset() on the array before passing it to exec().
If the return_var argument is present along with the array argument, then the return status of the executed command will be written to this variable.