Skip to content

PHP4 (.php4)

.php4 file signature | text/x-php

PHP4 is a legacy file format for PHP source code, maintained by the PHP Group as part of the PHP scripting language ecosystem. It is used for server-side web applications, dynamic page generation, and embedded scripting in HTML-based sites. PHP4 is an obsolete branch of PHP and is no longer supported, so files should be reviewed carefully when handling older web projects, although the format itself is not inherently dangerous.

Safe

Magic Bytes

Offset 0
3C 3F 70 68 70

Sources: Apache Tika

Extension

.php4

MIME Type

text/x-php

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .php4 files in Python

Python
def is_php4(file_path: str) -> bool:
    """Check if file is a valid PHP4 by magic bytes."""
    signature = bytes([0x3C, 0x3F, 0x70, 0x68, 0x70])
    with open(file_path, "rb") as f:
        return f.read(5) == signature

How to validate .php4 files in Node.js

Node.js
function isPHP4(buffer: Buffer): boolean {
  const signature = Buffer.from([0x3C, 0x3F, 0x70, 0x68, 0x70]);
  return buffer.subarray(0, 5).equals(signature);
}

How to validate .php4 files in Go

Go
func IsPHP4(data []byte) bool {
    signature := []byte{0x3C, 0x3F, 0x70, 0x68, 0x70}
    if len(data) < 5 {
        return false
    }
    return bytes.Equal(data[:5], signature)
}

API Endpoint

GET /api/v1/php4
curl https://filesignature.org/api/v1/php4

See the full API documentation for all endpoints and parameters.

Related Formats

Frequently Asked Questions

What is a .php4 file?

A .php4 file is identified by the magic bytes 3C 3F 70 68 70 at byte offset 0. PHP4 is a legacy file format for PHP source code, maintained by the PHP Group as part of the PHP scripting language ecosystem. It is used for server-side web applications, dynamic page generation, and embedded scripting in HTML-based sites. PHP4 is an obsolete branch of PHP and is no longer supported, so files should be reviewed carefully when handling older web projects, although the format itself is not inherently dangerous.

What are the magic bytes for .php4 files?

The magic bytes for PHP4 files are 3C 3F 70 68 70 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .php4 file?

To validate a .php4 file, read the first bytes of the file and compare them against the known magic bytes (3C 3F 70 68 70) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .php4 files?

The primary MIME type for .php4 files is text/x-php.

Is it safe to open .php4 files?

PHP4 (.php4) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.