PHP

PHP TutorialCompile PHP ExtensionsContributing to the PHP CoreContributing to the PHP ManualCreate PDF files in PHPInstalling a PHP environment on WindowsPHP Alternative Syntax for Control StructuresPHP APCuPHP Array iterationPHP ArraysPHP Asynchronous programmingPHP Autoloading PrimerPHP BC Math (Binary Calculator)PHP Built in serverPHP CachePHP Classes and ObjectsPHP ClosurePHP Coding ConventionsPHP Command Line Interface (CLI)PHP CommentsPHP Common ErrorsPHP Compilation of Errors and WarningsPHP Composer Dependency ManagerPHP ConstantsPHP Control StructuresPHP CookiesPHP CryptographyPHP DateTime ClassPHP DebuggingPHP Dependency InjectionPHP Design PatternsPHP Docker deploymentPHP Exception Handling and Error ReportingPHP Executing Upon an ArrayPHP File handlingPHP Filters & Filter FunctionsPHP Functional ProgrammingPHP FunctionsPHP GeneratorsPHP Headers ManipulationPHP How to break down an URLPHP How to Detect Client IP AddressPHP HTTP AuthenticationPHP Image Processing with GDPHP ImagickPHP IMAPPHP Installing on Linux/Unix EnvironmentsPHP JSONPHP LocalizationPHP LoopsPHP Machine learningPHP Magic ConstantsPHP Magic MethodsPHP Manipulating an ArrayPHP mongo-phpPHP Multi Threading ExtensionPHP MultiprocessingPHP MySQLiPHP MySQLi affected rows returns 0 when it should return a positive integerPHP NamespacesPHP Object SerializationPHP OperatorsPHP Output BufferingPHP Outputting the Value of a VariablePHP Parsing HTMLPHP Password Hashing FunctionsPHP PDOPHP PerformancePHP PHPDocPHP Processing Multiple Arrays TogetherPHP PSRPHP Reading Request DataPHP RecipesPHP ReferencesPHP ReflectionPHP Regular Expressions (regexp/PCRE)PHP Secure Remeber MePHP SecurityPHP Sending EmailPHP SerializationPHP SessionsPHP SimpleXMLPHP SOAP ClientPHP SOAP ServerPHP SocketsPHP SPL data structuresPHP SQLite3PHP StreamsPHP String formattingPHP String Parsing



Installing a PHP environment on Windows

From WikiOD

Remarks[edit | edit source]

HTTP services normally run on port 80, but if you have some application installed like Skype which also utilizes port 80 then it won't start. In that case you need to change either its port or the port of the conflicting application. When done, restart the HTTP service.

Download and Install XAMPP[edit | edit source]

What is XAMPP?[edit | edit source]

XAMPP is the most popular PHP development environment. XAMPP is a completely free, open-source and easy to install Apache distribution containing MariaDB, PHP, and Perl.

Where should I download it from?[edit | edit source]

Download appropriate stable XAMPP version from their download page. Choose the download based on the type of OS (32 or 64bit and OS version) and the PHP version it has to support.

Current latest being XAMPP for Windows 7.0.8 / PHP 7.0.8.

Or you can follow this:

XAMPP for Windows exists in three different flavors:

  • Installer (Probably .exe format the easiest way to install XAMPP)
  • ZIP (For purists: XAMPP as ordinary ZIP .zip format archive)
  • 7zip: (For purists with low bandwidth: XAMPP as 7zip .7zip format archive)

How to install and where should I place my PHP/html files?[edit | edit source]

Install with the provided installer[edit | edit source]

  1. Execute the XAMPP server installer by double clicking the downloaded .exe.

Install from the ZIP[edit | edit source]

  1. Unzip the zip archives into the folder of your choice.
  2. XAMPP is extracting to the subdirectory C:\xampp below the selected target directory.
  3. Now start the file setup_xampp.bat, to adjust the XAMPP configuration to your system.

Note: If you choose a root directory C:\ as target, you must not start setup_xampp.bat.

Post-Install[edit | edit source]

Use the "XAMPP Control Panel" for additional tasks, like starting/stopping Apache, MySQL, FileZilla and Mercury or installing these as services.

File handling[edit | edit source]

The installation is a straight forward process and once the installation is complete you may add html/php files to be hosted on the server in XAMPP-root/htdocs/. Then start the server and open http://localhost/file.php on a browser to view the page.

Note: Default XAMPP root in Windows is C:/xampp/htdocs/

Type in one of the following URLs in your favourite web browser:

http://localhost/
http://127.0.0.1/

Now you should see the XAMPP start page.

Installing_a_PHP_environment_on_Windows

Download, Install and use WAMP[edit | edit source]

WampServer is a Windows web development environment. It allows you to create web applications with Apache2, PHP and a MySQL database. Alongside, PhpMyAdmin allows you to manage easily your databases.

WampServer is available for free (under GPML license) in two distinct versions : 32 and 64 bits. Wampserver 2.5 is not compatible with Windows XP, neither with SP3, nor Windows Server 2003. Older WampServer versions are available on SourceForge.

WampServer versions:

Providing currently:

  • Apache: 2.4.18
  • MySQL: 5.7.11
  • PHP: 5.6.19 & 7.0.4

Installation is simple, just execute the installer, choose the location and finish it.

Once that is done, you may start WampServer. Then it starts in the system tray (taskbar), initially red in color and then turns green once the server is up.

You may goto a browser and type localhost or 127.0.0.1 to get the index page of WAMP. You may work on PHP locally from now by storing the files in <PATH_TO_WAMP>/www/<php_or_html_file> and check the result on http://localhost/<php_or_html_file_name>

Install PHP and use it with IIS[edit | edit source]

First of all you need to have IIS (Internet Information Services) installed and running on your machine; IIS isn't available by default, you have to add the characteristic from Control Panel -> Programs -> Windows Characteristics.

  1. Download the PHP version you like from http://windows.php.net/download/ and make sure you download the Non-Thread Safe (NTS) versions of PHP.
  2. Extract the files into C:\PHP\.
  3. Open the Internet Information Services Administrator IIS.
  4. Select the root item in the left panel.
  5. Double click on Handler Mappings.
  6. On the right side panel click on Add Module Mapping.
  7. Setup the values like this:
Request Path: *.php   
Module: FastCgiModule  
Executable: C:\PHP\php-cgi.exe  
Name: PHP_FastCGI  
Request Restrictions: Folder or File, All Verbs, Access: Script

Install vcredist_x64.exe or vcredist_x86.exe (Visual C++ 2012 Redistributable) from https://www.microsoft.com/en-US/download/details.aspx?id=30679

Setup your C:\PHP\php.ini, especially set the extension_dir ="C:\PHP\ext".

Reset IIS: In a DOS command console type IISRESET.

Optionally you can install the PHP Manager for IIS which is of great help to setup the ini file and track the log of errors (doesn't work on Windows 10).

Remember to set index.php as one of the default documents for IIS.

If you followed the installation guide now you are ready to test PHP.

Just like Linux, IIS has a directory structure on the server, the root of this tree is C:\inetpub\wwwroot\, here is the point of entry for all your public files and PHP scripts.

Now use your favorite editor, or just Windows Notepad, and type the following:

<?php 
header('Content*Type: text/html; charset=UTF-8');    
echo '<html><head><title>Hello World</title></head><body>Hello world!</body></html>';

Save the file under C:\inetpub\wwwroot\index.php using the UTF-8 format (without BOM).

Then open your brand new website using your browser on this address: http://localhost/index.php

Credit:Stack_Overflow_Documentation