Showing posts with label PHP Tutorials. Show all posts
Showing posts with label PHP Tutorials. Show all posts

Monday, January 21, 2008

Adrotator in PHP

Creating adrotaror is a simple step in PHP.

You will have to create two files, the source from which you want to load the advertisements and the source which will read the ads to load on your page.

You can create the ads.txt with following contents:


First Ad
--
Second Ad
--
Third Ad


Replace the text First Ad, Second Ad, Third Ad with your Ad text. You can ad unlimited number of ads as long as you split them with a seperator (here -- acts as a seperator)

Then create a rotator.php file with the following contents:

<?php
$filecontent = join ('', file ('ads.txt'));
$adarray = split("--",$filecontent);
$selectedad = rand(0,(count($adarray)-1));
echo $adarray[$selectedad];
?>



Thats it. You will have a random ad displayed wherever you include

<?php include "rotator.php" ?>

Wednesday, September 19, 2007

Installing PHP on IIS

Installing PHP with IIS is perhaps the easiest thing to do.

First download the PHP installer for Windows from PHP.net which should be located at http://www.php.net/downloads.php

Double click the installer and select the path to install PHP. You can install it anywhere you want. You should take care not to install it in a path with folder name which has a space. e.g. Program Files. The installer will ask you which server you want to configure with PHP, select the appropriate server and click Next till you finish the installation.

Other way to install PHP is to download the PHP zip file and extract it to the desired folder. Here you need to configure your IIS to recognize PHP. Follow instructions below to configure your server.

1. Click start -> RUN -> inetmgr
2. Right click on the default web site and properties
3. Select the isapi tab and click ADD
4. Type PHP as Filter name and Click on Browse under Executable
5. Browse to the folder where you extracted PHP and select php5isapi.dll
6. Click Home Directory Tab
7. Click on Configuration button to open Application Configuration window
8. Click on ADD button, and Click browse on Application Extension Mapping
9. Browse to the folder where you extracted PHP and select php5isapi.dll
10. Enter .php in the extension textfield
11. Click OK to return to Application Configuration
12. Click OK to return to properties

This will configure IIS to recognize PHP. You also need to do the following to complete the installation

1. Right Click on my computer and select Properties
2. Click on Advanced Tab
3. Click on Environment Variables
4. Under System Variables, Select PATH and Click Edit
5. Add ; and the path to PHP5 e.g ;D:\PHP5
6. Click OK
7. On Environment Variables, Click on ADD button
8. On New System Variable window, enter variable name as PHPRC and Variable value as Path to PHP e.g. D:\PHP5
9. Click OK till all windows are closed
10. RESTART windows

Remember to RESTART windows after the configuration

This finishes your PHP installation. You can test the installation by creating test.php file with following code:


<?php
phpinfo();
?>