PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am writing a PHP app that needs a function that can open a certain a PHP file on my server. then run the code on a certain line in that file. For simplicity's sake, let's say I have a file like this called commands.php:
i would think it would be much easier to make a folder, then have it just run one file in that folder. That way, youre not limited to one line of code, and can properly debug stuff much easier.
something like:
If you really need to do it this way then look at the fread() function as there is a way of doing it.
The issue that was raised is that it is much easier, faster and just plain better if you use an include file for each command as maliskoleather has suggested. It shouldn't be that hard to split the commands.php file into seperate files. If it is very large and don't want to do it by hand you could even write a function using fread() to do it for you.
You could also put the commands in an array in a single file and include that file then call the member of the array you want. Though this is not the best way to do it. But it doeas beat trying to read a file: commands.php