What are the requirements in running php?
In this tutorial we assume that your server has activated support for PHP and that all files ending in .php are handled by PHP. On most servers, this is the default extension for PHP files, but ask your server administrator to be sure. If your server supports PHP, then you do not need to do anything. Just create your .php files, put them in your web directory and the server will automatically parse them for you. There is no need to compile anything nor do you need to install any extra tools. Think of these PHP-enabled files as simple HTML files with a whole new family of magical tags that let you do all sorts of things. Show Let us say you want to save precious bandwidth and develop locally. In this case, you will want to install a web server, such as » Apache, and of course » PHP. You will most likely want to install a database as well, such as » MySQL. You can either install these individually or choose a simpler way. Our manual has installation instructions for PHP (assuming you already have some web server set up). If you have problems with installing PHP yourself, we would suggest you ask your questions on our » installation mailing list. If you choose to go on the simpler route, then » locate a pre-configured package for your operating system, which automatically installs all of these with just a few mouse clicks. It is easy to setup a web server with PHP support on any operating system, including MacOSX, Linux and Windows. On Linux, you may find » rpmfind and » PBone helpful for locating RPMs. You may also want to visit » apt-get to find packages for Debian. There are no user contributed notes for this page. What you need to run PHP on your computer and how to setup a WAMP server is explained in this tutorial. What You Need to Run PHP
You can separately install Web Server, PHP Interpreter, and MySQL databases, but to make work easier, developers have made all in one setup packages called WAMP, LAMP, MAMP, and XAMPP, which will automatically install and set up PHP environment on your Windows, Linux or MAC machines.
Start Where?To execute PHP code, you need access to a web server in which PHP is running. Your main options are:
or
Installing WAMP ServerCreating the ScriptYou need to use a text editor program to write your code. All OS comes with one or more text editors, for example:
Commercially, Adobe Dreamweaver, NetBeans, and Sublime Text are used to edit PHP code. XAMPP is a Web development tool, created by Apache, that makes it easy to run PHP (Personal Home Pages) scripts on your computer locally. Installation of XAMPP Server on windows is easy as compared to manual installation of a web server and PHP required a lot of in-depth configuration knowledge. XAMPP package installs MySQL, FileZilla, Mercury, Perl, and Tomcat along with Web Server and PHP, with these applications you can test the full website on your desktop. You don’t need to upload it every time on an online Web server. Step 1: First of all, open the Apache Friends website and download XAMPP for Windows, and install it. Step 2: Start the XAMPP Program Control Panel. Click on the “Start” button next to the “Apache” to start your Apache Web Server. Also, start “MySQL” if your PHP programs depend on a MySQL database to run. How to run PHP programs ? Step 3: Place your PHP files in the “htdocs” folder located under the “XAMPP” folder on your drive (i.e. C/D/E etc). The initial path is “your_drive_letter:\xampp\htdocs” for your Web server. Make sure that your PHP files are saved as a “.php” file extension. Example: The “demo.php” file is saved in the htdocs folder. PHP
How to run PHP programs ? Step 4: Open up any web browser and enter “localhost/filename”. This will open the list of all the files and folders stored under the “htdocs” folder on your computer. Click on the link to a PHP file and open it to run a program. Example: The file “demo.php” file is placed inside the “htdocs” folder. If you want to run it, open any web browser and enter “localhost/demo.php” and press enter. Your program will run. Syntax: php have special Syntax to write a code, as shown in below
demo.php PHP
How to run PHP programs ? Step 5: You can create any folder to test PHP files under the “htdocs” folder. If you create a specific folder then you need to use the address as “localhost/foldername” to open them in your browser. Example: The “demo.php” file is placed inside the “gfgdemo” folder. Enter “localhost/gfgdemo/demo.php” in your browser and press enter, your program will be run. How to run PHP programs ? PHP case sensitivity PHP is case sensitive language, in that variables and functions, tags are case sensitive but classes are not case sensitive. Below the example of case sensitivity of php. Example 1: echo.php PHP
In above code we write three different types of echo methods, see the output in the image. Output: How to run PHP programs? Example 2: color.php PHP
In the above example, the variable name is case sensitive, so it gives error. Output: My car is My dog is black My Phone is PHP Notice: Undefined variable: ColoR in HelloWorld.php on line 3 PHP Notice: Undefined variable: COLOR in HelloWorld.php on line 5 What are the steps to run PHP program?You just follow the steps to run PHP program using command line.. Open terminal or command line window.. Goto the specified folder or directory where php files are present.. Then we can run php code using the following command: php file_name.php.. Do you need a server to run PHP?Instead, you need PHP on a web server. It's the web server—not the web browser—that can interact with a PHP interpreter. Your browser can handle HTML on its own, but it has to make a request to a web server to deal with PHP scripts.
|