Archive for the 'Basics' Category
How to use PHP in pages with a .html extension (or any other)
5 Comments Published 2 years, 5 months ago in Basics and PHPTo be able to use php code on a page with an extension other than .php, you need a server which supports .htaccess files.
To add an extension to be parsed for php, create or edit a file called .htaccess (with the dot first) containing the following line:
AddType application/x-httpd-php .html .moo .htm
This tells the server […]
The Difference Between require() and include()
6 Comments Published 2 years, 5 months ago in Basics and PHPThe key difference between require() and include() is that if you require() a file that can't be loaded (eg if it isn't there) then it generates a fatal error which will halt the execution of the page completely, and no more output will be generated. On the other hand, if you include() a file that [...]
The problem: we have an array of items in PHP and we want to find out if a specific item is in the array. In code we can define the array as:
IE we have an array called $fruitBasket which contains 5 strings, each of which is the name of a fruit. We want to find [...]
To create random numbers in PHP, you can use the rand() function call, which takes either zero or, optionally, two parameters determining the minimum and maximum random numbers (inclusive) that you'd like. If you don't specify a maximum then it will default to a value, RAND_MAX, set in the PHP configuration. The function returns an [...]
The full URL to a page comes in three parts: The domain name, the path to the file then the filename, and the query string. For example, take the URL http://www.example.com/example/page.php?name=Bob. The three parts of this are:
1. The domain name: www.example.com2. The path to the page: /example/page.php3. The query string: name=Bob
So how do you find [...]
Do you want to know the IP address of a visitor? This can be useful for many reasons, such as tracking site usage or blocking access to specific people. Here's how you can find it using PHP.
In a PHP page, within the PHP tags, <?php ... ?>, you can retrieve the IP address of a [...]
This article shows you how to display a calendar for a given month, mainly using PHP's date() function.
The date() function
The date() function displays the date in your desired format, at a given time. It works by accepting one or two parameters, the first is a string with the format, the letters in the string tell [...]
This article tells you how to pass variables to a PHP page using the query string, and how to access them from that page.
Introduction
Have you ever seen a URL which looked like "www.example.com/page.php?mode=1&style=red"? Well, this page is being passed variables and their values through the query string, here the variables "mode" and "style" are being [...]
Search
About
You are currently browsing the DiscoMoose weblog archives for the 'Basics' category.
Longer entries are truncated. Click the headline of an entry to read it in its entirety.Categories
- ASP (3)
- ASP Basics (3)
- Blogs (2)
- C# (1)
- Firefox (1)
- Flash (1)
- Google (6)
- Hacks (3)
- Java (1)
- PHP (12)
- Basics (8)
- Files (1)
- Image Handling (3)
- Puzzles (1)
- Ruby (1)
- Tips (10)
- Web Hosting (3)
- Web Hosting Articles (1)
- Web Hosting News (2)
- Windows (6)
- Wordpress (2)
Latest
- Brainteaser: Which letter comes next?
- Hacking the translation plugin for nicer URLs
- How to Access a Page in Google’s Cache
- How to Control the Mouse Pointer Without a Mouse in Windows XP
- Use Google to define words
- List all processes with the Windows Command Line
- Kill a Process from the Windows Command Line
- Google: Search within a site
- Google Currency Conversion
- Save Embedded Media and Other Files in Firefox
Archives
Categories
- ASP (3)
- ASP Basics (3)
- Basics (8)
- Blogs (2)
- C# (1)
- Files (1)
- Firefox (1)
- Flash (1)
- Google (6)
- Hacks (3)
- Image Handling (3)
- Java (1)
- PHP (12)
- Puzzles (1)
- Ruby (1)
- Tips (10)
- Web Hosting (3)
- Web Hosting Articles (1)
- Web Hosting News (2)
- Windows (6)
- Wordpress (2)
