Reading and Writing Files in PHP
Writing Files
PHP offers multiple appproaches for writing data to files, ranging from low-level file pointer functions to convenient single-call wrappers.
Using fopen(), fwrite(), and fclose()
<?php
$fp = fopen("output.txt", "w") or die("Cannot open file");
$content = "First line of data\n";
fwrite($fp ...
Posted on Mon, 24 Aug 2026 16:12:03 +0000 by fer0an
Common Web Security Vulnerabilities and Practical Solutions
Viewing Page Source with Restricted Access
Some websites may disable the right-click context menu to prevent users from viewing the page source. To view the HTML source code, press Ctrl+U (or Cmd+Option+U on Mac) directly in the browser. Developers often hide sensitive data like flags within HTML comments.
<!-- Flag: FLAG{hidden_in_comment} ...
Posted on Mon, 24 Aug 2026 16:05:26 +0000 by Ajdija
Essential PHP Extensions and Their Core Capabilities
PHP’s capabilities can be significantly extended through compiled modules known as extensions. Below is a curated overview of widely adopted extensions grouped by functional domain, along with concise descriptions and practical usage notes.
Database Connectivity
PDO — A database abstraction layer offering consistent APIs across multiple backe ...
Posted on Sat, 22 Aug 2026 16:26:57 +0000 by anthonyw17
Setting Up a Local Web Development Environment on Windows
PHP Configuration
Download the latest PHP version from the official Windows repository. Extract the archive to a dedicated directory such as D:\WebDev\php-8.2.0.
Navigate to the extracted folder and create a working configuration file by copying php.ini-development and renaming it to php.ini.
Open the configuration file and locate the extension ...
Posted on Fri, 21 Aug 2026 16:53:07 +0000 by chixsilog
PHP RabbitMQ Tutorial - Part Three: Work Queues
Publish/Subscribe
In this tutorial, we will use PHP with the php-amqplib library to implement a publish/subscribe system. This pattern differs from work queues, where each task is delivered to exactly one worker. Instead, we will broadcast messages to multiple consumers.
Prerequisites
This tutorial assumes RabbitMQ is installed and running on l ...
Posted on Thu, 20 Aug 2026 16:54:59 +0000 by aquila125
Integrating MySQL Database with PHP in WeChat Mini Program
Preparation
1. Domain Registration
A domain name is required, and it must be registered.
2. Server Setup
A server is needed, and I use the BaoTa panel for ease of use.
Alternatively, a virtual host can be used, which is cost-effective for beginners.
The overall process involves using wx.request in the WeChat Mini Program JavaScript to fetch dat ...
Posted on Thu, 20 Aug 2026 16:49:24 +0000 by herghost
Installing PHP 7.4 via Yum on CentOS 7
Installation via Yum
Yum automates the instalation process by resolving and installing all required software dependencies. In CentOS 7, system services are managed with systemctl. A yum installation automatically registers the service, allowing you to start it with commands like systemctl start php74-php-fpm.service. The primary disadvantage is ...
Posted on Tue, 18 Aug 2026 16:15:04 +0000 by kemper
Role-Based Access Control Implementation in ThinkPHP 3.2.3
RBAC Architecture in CMS Development
This CMS system built on ThinkPHP 3.2.3 implements Role-Based Access Control (RBAC) for managing user permissions across various modules including content, products, users, roles, and system settings.
RBAC Core Concepts
RBAC operates on the principle that users are assigned to roles, and roles are granted pe ...
Posted on Mon, 17 Aug 2026 16:31:51 +0000 by adamddickinson
Implementing the Simple Factory Pattern in PHP
Simple Factory Pattern Overview
The Simple Factory Pattern decouples the client code from the object instantaition logic by centralizing creation inside a dedicated factory. The client requests objects from the factory instead of instantiating them directly, which improves maintainability and extensibility.
A key limitation is that adding or mo ...
Posted on Mon, 17 Aug 2026 16:13:56 +0000 by mmoussa
PHPExcel Implementation for Excel File Import and Export with Template Support
PHPExcel is a powerful library that provides comprehensive functionality for handling Excel files in PHP. This article covers reading Excel files and exporting data with template support.
Prerequisites
Download PHPExcel SDK from GitHub: https://github.com/PHPOffice/PHPExcel
Extract the SDK and integrate the class files into your project struct ...
Posted on Sun, 16 Aug 2026 17:01:15 +0000 by dadamssg