PHP4
text/x-php
Magic Bytes
Offset: 0
3C 3F 70 68 70
The PHP4 script format is a legacy server-side scripting language specification developed and maintained by The PHP Group. Developers primarily used these files to generate dynamic web content and interact with databases during the late 1990s and early 2000s. Although this specific extension is now largely obsolete in favor of the standard .php suffix, executing legacy scripts introduces severe security vulnerabilities and performance issues on modern server environments.
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);
}
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