Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lepharamramchiary/php_started


https://github.com/lepharamramchiary/php_started

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# PHP Learning Guide

Welcome to your first steps in learning **PHP**! This guide will help you get started with PHP basics, setup, and some beginner-friendly examples.

## What is PHP?

**PHP** (Hypertext Preprocessor) is a popular general-purpose scripting language that is especially suited for web development. It is fast, flexible, and widely used to create dynamic web pages.

## Prerequisites

Before you start learning PHP, make sure you have the following:

- **Basic understanding of HTML and CSS**: PHP is often embedded within HTML, so having basic HTML knowledge will help.
- **A web server and PHP installed**: You'll need a working PHP environment to run your code. See the setup section below for more details.

## Getting Started

### 1. Setting Up Your PHP Environment

To run PHP code on your local machine, you'll need a web server with PHP installed. You can do this in one of the following ways:

#### Using XAMPP (Recommended for Beginners)
- Download [XAMPP](https://www.apachefriends.org/index.html), which includes Apache (web server), MySQL (database), and PHP in a single package.
- Install XAMPP and start Apache from the XAMPP Control Panel.
- Place your PHP files in the `htdocs` folder inside the XAMPP installation directory (usually `C:\xampp\htdocs\` on Windows).
- Access your files in the browser at `http://localhost/your-file-name.php`.

#### Using VSCode + PHP Extension
- Install the **PHP Extension** on Visual Studio Code to get syntax highlighting and code formatting features for PHP.
- You can also run PHP scripts directly from the command line if you install PHP separately.

### 2. Writing Your First PHP Script

PHP code is written inside `` tags and embedded within HTML files. Here’s your first PHP script:

```php

```

## Enable Auto-Reload for PHP Using Live Server Chrome Extension

The Live Server Chrome extension allows you to auto-reload web pages when files change, but it doesn’t directly support server-side PHP processing. Therefore, you need to combine it with a local server like XAMPP or PHP's built-in server to handle PHP files, while Live Server handles auto-reloading.
### 1. Install Chrome Live Server Extension
- Open Chrome and navigate to the [Live Server extension](https://chromewebstore.google.com/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj).
- Click on **Add to Chrome** and install it.

### 2. Set Up Local PHP Server
- To run PHP, you need a local server like XAMPP or PHP’s built-in server

### 3. Configure Live Server Chrome Extension
- Once the Live Server extension is installed, you need to set it up to listen to file changes and reload your PHP pages:
- Open Chrome, and click on the Live Server extension icon.
- In the extension's popup, you'll see a field for entering your Actual Server Address and Live Server Address.

![php](https://github.com/user-attachments/assets/2a4a03b3-9f18-43d5-8c23-d8105e27ab43)