Как открыть php через xampp

How to Run a PHP File Using XAMPP: A Step By Step Guide

PHP Using XAMPP: The Ultimate Step-by-Step Guide

PHP is the most popular and widely-used server-side scripting language for web development. However, it requires a webserver to run even a locally developed webpage. There are various web server software for setting up our local webserver. Amongst them, PHP XAMPP and WampServer are the most popular. While WampServer is only available for the Windows platform, XAMPP is a cross-platform application that can run on Windows, Linux, and macOS. Hence, in this tutorial, you will learn PHP using XAMPP.

What Is PHP?

PHP (Hypertext Protocol) is Open Source Programming Language used to make web pages. PHP language can run on various platforms and is compatible with almost all servers. PHP files use .php as their extension. PHP can perform functions, like from files on a system it can create, open, read, write, and close them. You can add, delete, and modify elements within your database with the help of PHP. You can restrict users from accessing some pages of your website using PHP. PHP can encrypt data too.

Advantages Of PHP

Web-Developers use many other languages, but most prefer using PHP because of its advantages. Some advantages of PHP are:

  1. Simple and easy to learn — PHP is known as the easiest Scripting language as it doesn’t have intensive studying. Commands are very easy to understand for new learners and developers too.
  2. Compatible — PHP language is compatible because it can run on many operating systems. It can easily run on platforms like Windows, LINUX, and UNIX.
  3. Flexibility — PHP language is very flexible for developers because it allows you to change the existing or completed project.
  4. Less Costly — As PHP is an open-source language, you can download it for free. You don’t have to purchase any license or software.
  5. MVC Pattern — Model-View-Controller Pattern in PHP helps you organize codes.
  6. Loading Time — PHP is faster than other programming languages. It can be loaded when your network connection is slow.
  7. Library Support — PHP also has a collection of many, many advanced written codes that you can use repeatedly. And also use it whenever you want to run a program.

How to Set Up and Install PHP for Your Project?

Step 1: Find a web server that supports PHP and MYSQL.

Step 2: Then install PHP from its website.

Step 3: Then install MYSQL DB on your PC.

What is XAMPP?

XAMPP is an open-source web server solution package. It is mainly used for web application testing on a local host webserver.

Now that you have a better understanding of the XAMPP software, let us move on to its installation.

Why Do You Need XAMPP?

To run any PHP program, you will need Apache or MYSQL databases, both supported by XAMPP. XAMPP helps you to run your program smoothly.

Читайте также:  Создать свое меню css

Basics to Advanced — Learn It All!

How to Install XAMPP?

Apache friends developed XAMPP, and it is available for everyone free of cost.

You can download XAMPP through the official website, https://www.apachefriends.org/download.html.

On completing the download of the setup file, begin the installation process and, in the “Select Components” section, select all the required components.

XAMPP_1

Next, select the directory where you want the software to be installed. It is recommended that you keep the default directory “C:\xampp” and click on “next” to complete the installation.

XAMPP_2

Now that the installation is complete, let’s move ahead to see how to run a PHP script using the same.

How to Start a New PHP Project in XAMPP?

  • Before you run or start writing any program in PHP, you should start Apache and MYSQL.
  • After starting both servers, you have to write a program in Notepad.
  • After writing it, save that file as «program.php».
  • Then copy that file program.php to C:/Program Files/XAMPP/htdocs.
  • Open the browser and type http://localhost.
  • Now run your code in that browser.

Designing a Social Media App Like Instagram

How to Run a PHP Code Using XAMPP?

Before running a PHP script, you must know where to write it.

In the XAMPP directory, there exists a folder called “htdocs”. This is where all the programs for the web pages will be stored.

1. Go to “C:\xampp\htdocs” and inside it, create a folder. Let’s call it “demo”. It’s considered good practice to create a new folder for every project you work on.

XAMPP_3

2. Inside the demo folder, create a new text file and name it “index.php” and write the following script.

XAMPP_4.

3. Now, to see the script output, open the XAMPP control panel and start Apache to host the local webserver, where our script will be running.

XAMPP_5

4. Now navigate to your browser and type in “localhost/demo/” in the address bar to view the output.

/first_php_script_xampp_6

Congratulations, with this, you have created a PHP file and also executed the program successfully.

Conclusion

This concludes the tutorial. In this “PHP using XAMPP” tutorial, you looked into why you need XAMPP, what XAMPP is, how to install XAMPP, and finally, how to run your first PHP script on it.

Are you planning to take the plunge and do a course on PHP? In that case, Simplilearn’s PHP course would be an excellent choice. The Post Graduate Program in Full Stack Web Development covers all the fundamental and advanced concepts, making your journey towards learning PHP an easy one.

If you have any questions regarding the “PHP using XAMPP” tutorial, please ask away in the comments section of this article, and we’ll have our experts answer them for you.

FAQs

1. How to run a PHP file in localhost XAMPP?

Create any project, for e.g.,

2. Can we run PHP in XAMPP?

Yes, you can run PHP in XAMPP. First, start the XAMPP server, create a program you want to and run it at http://localhost.

3. How do I run my PHP file?

PHP files are saved in C:/Program Files/XAMPP/htdocs. You have to open it, click on the program, and it will automatically run on localhost.

4. How to run PHP files in phpMyAdmin?

  • Login into PHPMyAdmin, then click on the import tab.
  • Browse the file with a .sql extension.
  • Keep in mind to check and uncheck some options.
  • Choose SQL format and click on Go.

Find our Full Stack Java Developer Online Bootcamp in top cities:

Name Date Place
Full Stack Java Developer Cohort starts on 4th Aug 2023,
Weekend batch
Your City View Details
Full Stack Java Developer Cohort starts on 25th Aug 2023,
Weekend batch
Your City View Details
Читайте также:  Сортировка пузырьком python матрицы

About the Author

Ravikiran A S

Ravikiran A S works with Simplilearn as a Research Analyst. He an enthusiastic geek always in the hunt to learn the latest technologies. He is proficient with Java Programming Language, Big Data, and powerful Big Data Frameworks like Apache Hadoop and Apache Spark.

Full Stack Java Developer Career Bootcamp

Источник

How to Run a PHP File in XAMPP 2022 VStep by Step Tutorial

How to Run a PHP File in XAMPP: Step by Step Tutorial

If you program in PHP, you’re in luck, since running PHP files in XAMPP is a piece of cake. Read on to find out how to do this.

The XAMPP suite of Web Development Tools developed by Apache Friends makes it easy to run PHP scripts (Personal Home Pages) on your computer locally.

Manual Web server and PHP installation require in-depth configuration experience, but installing XAMPP on Windows only needs an installer kit to be running.

This kit installs not only a Web and PHP server but also MySQL, flagella, Mercury, Perl, and Tomcat. These applications allow testing of full websites on your own desktop without the need to upload everything to an online Web server.

What is Xampp?

XAMPP is a cross-platform and open-source web server package. It is completely free to download and Apache Friends develops and updates use.

The major components include the Apache HTTP Server and the MariaDB database. Also included are the interpreters that can read Perl and PHP scripts.

XAMPP is compatible with Linux, Windows, and Mac operating systems, making it a super-versatile server solution. It also supports LAMP and WAMP stacks.

XAMPP is an acronym, with the letters standing for the following:

  1. X is for cross-platform
  2. A is for the Apache server
  3. M is for the MariaDB database (it used to stand for MySQL)
  4. P is for PHP
  5. P is for PERL

How to Open and Run a PHP File in XAMPP

How to Open and Run a PHP File in XAMPP

Opening and running PHP files in XAMPP is easy and simple. All you need is a working copy of XAMPP and a PHP file. Let’s see how you can do this.

STEP 1

First, let’s get XAMPP. You’ll need to get an appropriate version for your operating system from the Apache Friends’ official site. Launch your favorite web browser and go to https://www.apachefriends.org/index.html.

When the Home page of the site opens, you should click on the latest version of the program for your operating system. At the time of this writing, PHP 7.3.7 is the latest one for all three major OS platforms.

Click on the one you need to download.

STEP 2

Next, you should install XAMPP on your computer. The most common practice is to install it on the C drive, though some users opt to install it on D or other non-system partitions.

To install XAMPP, double-click on the installer file you downloaded. Click on the Run button to start the installation. Follow the installation wizard to complete the installation.

However, In the Select Components section, you can opt to leave some components out if you’re sure you won’t need them. However, it is recommended to keep everything as is and install the full version.

The default location is C:\xampp. You can change it if you want to, but it is recommended not to.

Read Also:

STEP 3

In this step, you’ll create the project folder where you’ll save the PHP file you’d like to run in XAMPP. To do that, go to your XAMPP folder. If you haven’t altered installation options, they installed your copy of XAMPP on the C drive.

Читайте также:  Learning java code for beginners

Once you get to the XAMPP’s main folder, go to the htdocs folder. There, create a new folder and name it after the file you’ll copy into it. Alternatively, you can name it “NewProject,” “Project 1,” or give it any other name.

STEP 4

If you already have a file that you want to open with XAMPP, browse for it. Once you’ve located it, copy and paste it into the folder you created in the previous step. You can also cut and paste the file.

If you don’t have the file and you want to create your first PHP file to test XAMPP, here’s what to do. Go to the folder you created in the previous step and create a new text file in it.

Name the file and change its extension from txt to php. Before we start, here is a word of warning: don’t enter the full stops at the end of the commands, as they are only there for grammatical purposes.

Open the file with a text editor, both Notepad and Notepad ++ will be good. Start your HTML document with . In the next row, open the header with (Title). Close the header in the next row with .

Next, open the body container with in the next row. Press Enter a few times and press TAB for indent. Type in . Press Enter once or twice and write the following command print “text”.

Between the quotations, you should write what you want to see when you open the file with XAMPP.

Press Enter once more and type ?>. This will end the PHP section. In the next row, you should type . In the row below that one, you should type .

Press Ctrl and S keys on your keyboard to save the changes to the file. Your file might look like this at the end:

STEP 5

Now, let’s open the file with XAMPP. Here’s how to do it:

  1. Launch XAMPP. You can open it via the status bar icon or search for it in the Start menu if you’re on a Windows computer.
  2. Once the app opens, you will see its Control Panel. Click on the Start button in the Apache row. This will launch the Apache server. The Apache label in the Module column will turn green and you’ll see a message in the log at the bottom of the Control Panel informing you that the server is running.
  3. Now, open your browser and type “localhost” into the address bar (omit the quotations).
  4. You should see the “localhost – Welcome to XAMPP” option right below the address bar. Click on it.
  5. You will be redirected to localhost/dashboard. Replace the dashboard part with the name of the folder where your PHP file is located. In our case it looks like this: localhost/NewProject.
  6. You will see the list of files in the said directory. Click on your PHP file.

If everything’s OK, you should see your PHP file open in your browser.

Read Also:

In Conclusion, as a free and open-source solution, XAMPP is a common option for web developers and testers running on a tight budget.

What’s more, many professionals use it, too. The fact that it’s compatible with Linux, Windows, and Mac makes it even more popular.

There is never a time that isn’t right to help. If this information was useful to you, do well to share it with friends and loved ones. It’s your turn to help other people.

You can share this article on your favorite social media handle.

Источник

Оцените статью