logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ how to run a php file in xampp

How to run a php file in xampp

by Admin _ April 28, 2022
3 Run Your First PHP Script4 Manage MySQL with PhpMyAdmin5 Run PHP Script with Database9 Some Notes

Overview

Setting up a development environment for PHP programming is easy. Download the code editor you prefer, I personally lượt thích atom.io text editor.

Bạn đang xem: How to run a php file in xampp

Next is to install XAMPP, the most popular PHP development environment. This package contains Apache, PHP & MariaDB or MySQL database applications.

Many people emailed me with a main question: Mike, how khổng lồ run a PHP script? This post is my answer to you guys and to those people who will need this in the future.

In the following tutorial, we will learn how to lớn install XAMPP, how to run a PHP script, manage database with PhpMyAdmin & run a sample PHP script that fetches a record from the database.

Install XAMPP

Go to lớn this links and download XAMPP for your operating system. XAMPP is available for Windows, Linux or Mac.

Here’s a video clip about how you can install và use XAMPP.


Run Your First PHP Script

The following is an example about how to lớn run a PHP script. What this program does is show a “Hello World!” text on the screen or webpage.

Go to lớn XAMPP server directory

I’m using Windows, so my root vps directory is “C:xampphtdocs”.

Create hello.php

Create a file & name it “hello.php“

Code Inside hello.php

Open hello.php and put the following code.


Open New Tab

Run it by opening a new tab in your browser

Load hello.php

On you browser window, type http://localhost/hello.php

Output

You should see the following output.

*

Create a Table

Click “my_first_database” on the left side of the screenOn the “Create Table” section, fill out the Name with “products” and Number of Columns with “6“Click “Go” button
*

Insert Data

Click the “products” table.

*

Click the “Insert” tab.

Xem thêm: What We Do - Day Trading: Your Dollars At Risk

*

Fill out the form, mimic the data on the following image. Click the “Go” button.

*

Great job! We now have a database, a table inside the database & a record inside the table.

*

Useful Videos

1. Create a database & import MySQL file.


2. Create a database và create table.


Run PHP Script with Database

In the following steps, we will run a PHP script that fetches one record from the MySQL database.

Go to lớn XAMPP server directory

Go to lớn your “C:xampphtdocs” directory

Create read_one.php

Create a file and name it “read_one.php“

Code Inside read_one.php

The numbers 1-8 in the following code are called “code comments”. It explains each part of our simple code below. Open read_one.php & put the following code.


prepare( $query ); // 4. Sample product ID$product_id=1; // 5. This is the first question mark in the query$stmt->bindParam(1, $product_id); // 6. Execute our query$stmt->execute(); // 7. Store retrieved row to lớn the "row" variable$row = $stmt->fetch(PDO::FETCH_ASSOC); // 8. Show data to lớn userecho "
Name: " . $row["name"> . "
";echo "
Description: " . $row["description"> . "
";echo "
Price: $" . $row["price"> . "
";?>

Open Your Browser

Run it by opening you your browser

Load read_one.php

On you browser window, type http://localhost/read_one.php

Output

You should see the following output.

*
Awesome! You are now ready khổng lồ learn more about website programming & development.

Online Resources

Here in darkedeneurope.com, we want to simplify learning for you lớn actually build something. But it is also important for you lớn read và study more. The following are my suggestions where lớn learn more.

You can always go back khổng lồ the menu above while you go along our series of web programming tutorials.

What’s Next?

Learn our JavaScript tutorial for beginners.

Related Tutorials


We listed all our high chất lượng full-stack website development tutorials here: Click here.

Some Notes


Found An Issue?

If you found a problem with this code, please send us an email. Before you send an email, please read our our code of conduct. Our team"s thư điện tử address is

Please be descriptive about your issue. Please provide the error messages, screenshots (or screen recording) and your chạy thử URL. Thanks!

Subscribe lớn darkedeneurope.com

Receive valuable web development tutorials khổng lồ your email. Subscribe now for FREE!

Share Tweet Linkedin Pinterest
Previous Post

Sprintf trong php

Next Post

Array concat php

CÙNG CHUYÊN MỤC

form register php

Form register php

09/04/2021
fantastic blog (cms) in php with source code

Fantastic blog (cms) in php with source code

28/04/2021
validate form php javascript

Validate form php javascript

28/04/2021
http diendanlequydon com viewtopic php style 6

Http diendanlequydon com viewtopic php style 6

28/04/2021
chủ đề: tách từng chữ trong chuỗi với php

Chủ đề: tách từng chữ trong chuỗi với php

26/05/2022
cách làm website bằng php

Cách làm website bằng php

25/05/2022
hướng dẫn cài đặt và sử dụng composer trên ubuntu 20

Hướng dẫn cài đặt và sử dụng composer trên ubuntu 20

25/05/2022
so sánh giờ trong php

So sánh giờ trong php

25/05/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Thai 30 tuần chưa quay đầu

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.