Reputation: 21465
In PHP how can I detect if I am running on an arm64 CPU or not? (as opposed to, for example, an AMD64 CPU)
Upvotes: 2
Views: 785
Reputation: 21465
The solution seems to be php_uname("m"), but it is trickier than one would expect. This is because we have observed different values for php-running-on-macos (PHP 8.1.3, "arm64") versus php-running-in-linux-docker-container-running-on-macos (PHP 7.4.28, "aarch64"), sooo we have to check for both???
// have been in a situation where MacOS-php says
// "arm64" while php-in-docker-linux-container-running-on-macos
// says "aarch64"...
$isArm64 = (false!==stripos(php_uname("m"), "aarch64") || false!== stripos(php_uname("m"),"arm64"));
Upvotes: 2