Questions and Answers:
How to write a Phip coding to list out all files and directories as links to them?
W to write a Phip coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder toge there with previous ones after it is being refreshed. (prefer in alphabetical order) how to achieve this sort of functionality in php? Please provide sample coding as well. (and any references) thanks.
Answer: // get array of all files and directories in the current directory (it is sorted alphabetically by default) $dir_entries = scandir(dirname(__file__); // for Phip 5. 3+, use Dir instead of dirname(__file__) // split the array of files and directories into two arrays, one containing files and the other diretcories $dir_files = array(); $dir_diretcories = array(); foreach($dir_entries as $dir_entry) { if(is_dir($dir_entry) { array_push($dir_diretcories, $dir_entry); } else { array_push($dir_files, $dir_entry); } } // print diretcories foreach($dir_diretcories as $dir_diretcory) { // don't print current and parent diretcories if($dir_diretcory == '. ' or $dir_diretcory == '.. ') { continue; } echo "<a href=\"". Htmlspecialchars($dir_diretcory). "\">". Htmlspecialchars($dir_diretcory). "</a><br/>\n"; } // print files foreach($dir_files as $dir_file) { echo "<a href=\"". Htmlspecialchars($dir_file). "\">". Htmlspecialchars($dir_file). "</a><br/>\n"; }
How to get a Phip file to be include ed across files in different diretcories?
Recently I have created some Phip based web pages and uploaded them to my web hosting server. It has a Phip 5. 1. 6 installed. With this I am able to include files only that are in the same diretcory(they work well using require() fn). If not an error message displaying some "no such file" in directory appears in the page. I would like to use them to be include ed in different directories. What should I do?
Answer: Create the directories and include the names when using the require() function. Example : your index. Phip is in the root diretcory /index. Php and you have a directory with your other Phip files in /lib/othere. Php so in index. Phip you will have require("lib/othere. Php");
How to include elements from different web pages using Phip or java script to my home page?
Have a homepage (myhome. Php). On the homepage, i'd like to display the latest 3 posts from another page (post. Php). For example. I want to include the first 3 <h1> tags from post. Phip into a <div> tag on my home. Phip. Is it possible to do this?
Answer: There could easily be better ways to do this, but without actually seeing how your data is organized I only have one workable suggestion. In post. Phip, add each post to array and then echo the array contents to output the posts. Then include post. Phip in homepage. Phip. Post. Php ------------- $post = array(); $post[0] = "<h1>post #1</h1>this is post #1"; $post[1] = "<h1>post #2</h1>this is post #2"; $post[2] = "<h1>post #3</h1>this is post #3"; foreach ($post as $x) { echo $x; } echo "<h1>more posts</h1>more posts here! "; myhome. Php ------------------- require_once('post. Php'); // gives you access to all the stuff in post. Php echo "let's see the first three posts:<br />"; foreach ($post as $x) { echo $x; } echo "stuff on homepage other than top posts. ";
How can I study or try Phip programming at home if I only have a laptop with Windex Sp os?
Want to learn Phip programming but I do not have that big server computers or a network of computers. Is it possible to do Phip programming using only a laptop connoted only to Internet, through a G modem; and running on windows P Sp os? What are the application and/or software that I need to install to make it work?
Answer: You could install camp. That will give you Apache web server, Phip and muscle. It's fairly easy to install and setup. See fist link below. But do make sure you secure it once installed, otherwise your machine could be vulnerable. Also not hard to do, read the instructions in the second link.
What is the Phip regular expression to get everything before a certain character?
R instance, I have the following string: table:column i need to get "table" as the result of the Phip regular expression. So, I need everything before the ":" symbol after that regular expression is performed, I would also like to get everything after the ":" symbol, or "column" as well.
Answer: If you only have one ":" symbol in the string, you can use this: $string = explode(":", $string); this puts the two halves into an array. So: $table = $string[0]; $column = $string[1];
Answers are checked for grammar, and punctuation, not for accuracy, do not make any life threatening, or financial decisions based on this information.
![glogo[1]](/glogo.gif)