Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cast Are Case Insensitive

<?php

$a = (int) $b;
$a = (INT) $b;
$a = ( int) $b;
$a = ( int ) $b;
$a = (int ) $b;
$a = (     int    ) $b;
?>

Today I learned that PHP cast operators like (int) and (array) are case-insensitive—so (STRING) works just as well. Additionally, the amount of whitespace (spaces, tabs, etc.) around these casts doesn’t affect functionality. These aspects are flexible in PHP, and what remains—such as casing and spacing style—is largely a matter of coding convention and personal or team preference.

See Also

PHP Features

Last updated: 10 September 2026