Resources, Articles, Tricks, and Solutions in connection to PHP

PHP header not redirecting error

This article will guide you on ways to fix #PHP #header not #redirecting error which generally occurs mainly due to the absence of ob_start() function, incorrect header formats, and so on. Your target destination server does not allow iframe redirects. Fix: Servers can solely determine if websites hosted on them can be reached via an #iframe redirect. The easiest way to resolve this is to simply change your selection from "Redirect using iframe" to "Redirect URL".

To redirect URL in PHP:

1. You can simply use the PHP header() function to redirect a user to a different page. 

2. The PHP code in the following example will redirect the user from the page in which it is placed to the URL . 

3. You can also specify relative #URLs.

Read More

How to tell if its a leap year with PHP

This article will guide you on how to work with PHP date() function to work out if the current year, or a specific year, is a leap year or not. 

JavaScript is the client side scripting language and PHP is the server side scripting language. In #PHP, HTML is used as a string in the code. In order to render it to the browser, we produce JavaScript code as a string in the PHP code.

PHP #program to check if a year is leap year or not:

php #function year_check($my_year) { if ($my_year % 400 == 0) print("It is a leap year"); if ($my_year % 4 == 0) print("It is a leap year"); else if ($my_year % 100 == 0) print("It is not a leap year"); else print("It is not a leap year"); } $my_year = 2024; year_check($my_year); ?>

Read More

PHP-FPM Code and FileSystem Layout for EasyApache 4

This article will guide you on how PHP FastCGI Process Manager (PHP-FPM) daemon works. PHP-FPM Code and FileSystem Layout for EasyApache allows the website to handle loads. 

As PHP-FPM receives a proxied connection, a free PHP-FPM worker accepts the web server's request. PHP-FPM then compiles and executes the PHP script, sending the output back to the web server. Each PHP user can have its own separate pool of worker processes for handling PHP requests.

FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features (mostly) useful for heavy-loaded sites. These features include:

i. Ability to start workers with different uid/gid/chroot/environment.

ii. listening on different ports and using different php. ini (replaces safe_mode).

Read More

PHP-FPM performance tuning for high traffic website

This article will help to solve high load issue due to PHP-FPM service in order to boost web server performance.

Read More

Running multiple versions of PHP on Apache PHP-FPM

This article will guide you through the steps you need to take to run multiple PHP versions on Apache PHP-FPM. We implemented this on Ubuntu 20.04 server handling two websites with two different PHP versions (PHP 7.2 and 7.3).

Read More