PHP Articles

Page 7 of 81

How to Check form Submission in PHP?

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 3K+ Views

To check form submission in PHP, you can use several methods to determine if a form has been submitted and process the data accordingly. The most common approach is checking the request method or specific form fields. Method 1: Checking Request Method The most reliable way is to check if the request method is POST ? Method 2: Using isset() Function You can check if a specific form field or submit button exists ? Complete Example HTML Form (index.html) ...

Read More

How to Change the Maximum Upload file Size in PHP

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 357 Views

In PHP, the maximum upload file size is controlled by configuration directives in the php.ini file. By default, PHP sets relatively low limits for file uploads, but you can modify these settings to accommodate larger files. Key Configuration Directives Two main directives control file upload limits − upload_max_filesize − Maximum size for individual uploaded files post_max_size − Maximum size for the entire POST request (should be larger than upload_max_filesize) Step-by-Step Configuration Step 1: Locate php.ini File Find your php.ini file location. For XAMPP users, it's typically located at C:\xampp\php\php.ini. You can also ...

Read More

How to Calculate the Difference Between two Dates in PHP?

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 10K+ Views

Calculating the difference between two dates is a common requirement in PHP applications. PHP provides several approaches to achieve this, from simple mathematical calculations to object-oriented methods using the DateTime class. Using date_diff() Function The date_diff() function calculates the difference between two DateTime objects and returns a DateInterval object representing the time difference − +6 years 0 months Using Mathematical Formula with Timestamps This approach converts dates to Unix timestamps and uses mathematical calculations to determine the difference in years, months, days, hours, minutes, and seconds − ...

Read More

Enumerations in PHP

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 272 Views

Enumerations in PHP provide a way to define a fixed set of named constants, making your code more readable and preventing invalid values. While older PHP versions required workarounds, PHP 8.1 introduced native enum support. Native Enums (PHP 8.1+) PHP 8.1 introduced true enumeration support with the enum keyword − Order status: PENDING Order status: APPROVED Backed Enums Backed enums allow you to assign specific values to enum cases − Priority value: 3 Priority name: HIGH From value 2: MEDIUM Legacy ...

Read More

How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 743 Views

In PHP, the double equals (==) and triple equals (===) are comparison operators used to compare values for equality. However, they differ in terms of their behaviour and the level of strictness in the comparison process. Double Equals (==) The double equals operator checks for equality between two values, but it performs type coercion if the two values have different data types. This means that PHP will attempt to convert the values to a common type before performing the comparison. Here are some key points about the double equals operator − If ...

Read More

Determine The First And Last Iteration In A Foreach Loop In PHP

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 3K+ Views

In PHP, foreach loops don't provide built-in methods to identify the first and last iterations. However, you can use counter variables or array functions to determine when you're at the beginning or end of the loop. Method 1: Using Counter Variable The most straightforward approach is to track iterations with a counter variable − First item: 1 Current item: 1 Current item: 2 Current item: 3 Current item: 4 Last item: 5 Current item: 5 Method 2: Using Array Key Functions PHP provides functions to get the first and ...

Read More

Deleting All Files From A Folder Using PHP

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 1K+ Views

In PHP, you can delete all files from a folder using built−in functions like glob() and scandir(). Both methods provide efficient ways to iterate through directory contents and remove files programmatically. Using glob() Function The glob() function searches for files matching a specified pattern and returns an array of file paths ? Syntax array|false glob(string $pattern, int $flags = 0) Parameters $pattern − The search pattern (e.g., "folder/*" for all files) $flags (optional) − Modifies behavior with flags like GLOB_ONLYDIR, GLOB_NOSORT ...

Read More

Binary Search in PHP

Pradeep Kumar
Pradeep Kumar
Updated on 15-Mar-2026 2K+ Views

Binary search is a search algorithm used to find the position of a target value within a sorted array efficiently. It works by repeatedly dividing the search range in half and comparing the middle element with the target value. How Binary Search Works The binary search algorithm follows these steps − Start with the entire sorted array and set left pointer to first element, right pointer to last element. Calculate the middle index as the average of left and right pointers (integer division). Compare ...

Read More

How to prevent XSS with HTML/PHP?

Mohit Panchasara
Mohit Panchasara
Updated on 15-Mar-2026 809 Views

Cross-Site Scripting (XSS) is a major threat to web application security because it allows attackers to inject malicious scripts into reputable websites. This attack depends on innocent consumers, exposing important information or potentially gaining control of their accounts. Understanding and combating XSS threats is critical for maintaining a strong security posture as web applications become more complex and dynamic. What are XSS Attacks? Cross-Site Scripting (XSS) attacks are a common security risk in web applications. Attackers take advantage of vulnerabilities in web pages to inject and execute malicious scripts on the browsers of unaware users. The Different ...

Read More

Difference Between JSP and PHP

Shriansh Kumar
Shriansh Kumar
Updated on 15-Mar-2026 1K+ Views

Both JSP and PHP are two popular technologies that serve to create dynamic web pages. Both are similar in the ways that they allow developers to embed code within an HTML document that can interact with databases, sessions, cookies, and other web features. However, they also have some significant differences that may affect the choice of which one to use for a web project. In this article, we will explore the difference between JSP and PHP in terms of their syntax, performance, scalability, security, and compatibility. What is JSP? JSP stands for Java Server Pages and is used ...

Read More
Showing 61–70 of 802 articles
« Prev 1 5 6 7 8 9 81 Next »
Advertisements