Posts

Showing posts from August, 2012

Name a new feature introduced with PHP 5

PHP 5 introduces (among other things) SQLite support, improved XML support, and a significantly improved object model.

Will the include() statement slow down my scripts?

Because an included file must be opened and parsed by the engine, it will add some overhead. The benefits of reusable code libraries often outweigh the relatively low performance overhead, however.

Q: - Can I create arrays for values entered into elements other than select and check box fields?

Yes, in fact any element name ending with empty square brackets in a form resolves to an array element when the form is submitted. You can use this fact to group values submitted from multiple fields of any type into an array.

How to Execute PHP from a .html File

How can I execute PHP code on my existing myfile.html page? When a web page is accessed, the server checks the extension to know how to handle the page. Generally speaking if it sees a .htm or .html file, it sends it right to the browser because it doesn't have anything to process on the server. If it sees a .php extension (or .shtml, or .asp, etc), it knows that it needs to execute the appropriate code before passing it along to the browser. Here is the problem: You find the perfect script, and you want to run it on your site, but you need to included PHP on your page for it to work. You could just rename your pages to yourpage.php instead of yourpage.html, but you already have incoming links or search engine ranking so you don't want to change the file name. What can you do? First let me preface this by saying that if you are creating a new file anyway, you may as well use .php. This is to help people who have existing .html pages they need to execute

What Is My IP?

Show your user's their IP address: Retrieving the user's IP address is actually much simpler than you might think, and can be done in a single line. Getenv("REMOTE_ADDR") will return the IP address of the person visiting your site. Generally this is accurate, however if the user is running through a proxie server, then it will return the address of the proxie. In this example, we retrieve the user's IP and then simply echo it's value back to the user.   <?php    //Gets the IP address $ip = getenv("REMOTE_ADDR") ; Echo "Your IP is " . $ip;    ?>