This document discusses making PHP more interoperable across platforms. It covers differences between UNIX/Linux and Windows filesystem permissions and access times. It also discusses PHP performance optimizations like opcode caching, compiler optimizations, and differences between 32-bit and 64-bit PHP. Additionally, it covers threading versus processes in PHP and differences in SAPIs like Apache. The document provides code examples to illustrate concepts.
11. Interoperable PHP
File/process permissions
• UNIX/Linux
• chmod(), chown(), etc.
• process permissions are handled same way as file ones
• Windows
• icacls
• impersonation
• Unmapped UNIX users built-in SID mapping
12. Interoperable PHP
Access time
• ext3, ext4 and others
• noatime,nodiratime in /etc/fstab
• NTFS
• fsutil behavior query DisableLastAccess
• fsutil behavior set DisebleLastAccess 0
13. Interoperable PHP
NTFS streams
C:tmp> echo hello > foo.txt
C:tmp>echo world > foo.txt:bar.txt
C:tmp>dir /r foo.txt
Volume in drive C is SYSTEM
Volume Serial Number is AE0A-76BD
Directory of C:tmp
08/31/2015 11:50 PM 8 foo.txt
8 foo.txt:bar.txt:$DATA
1 File(s) 8 bytes
0 Dir(s) 59,944,050,688 bytes free
16. Interoperable PHP
PHP FS snippet 3
<?php
$f = fopen("file.txt", "w");
var_dump(unlink("file.txt"));
// Windows
Warning: unlink(file.txt): Permission denied in Command line code on line 1
bool(false)
//Linux
bool(true)
17. Interoperable PHP
PHP FS snippet 4
<?php
var_dump(fopen("some/directory", "r"));
// Windows
Warning: fopen(some/directory): failed to open stream: Permission denied in
Command line code on line 1
bool(false)
//Linux
resource(5) of type (stream)
33. Interoperable PHP
64- vs 32-bit in PHP
64-bit
• In general slower
• 9.22337204 × 109 GB
RAM addressable
• 64-bit integers
• LFS
• 64-bit string length
32-bit
• In general faster
• Less than 2 GB RAM
addressable
• 32-bit integers
• 32-bit file operations
• 32-bit string length
34. Interoperable PHP
Types in PHP7
• zend_long for integers
• zend_ulong for numeric hashes
• size_t for string length
• zend_off_t for file offsets
• zend_stat_t for file status information
• See UPGRADING for more info
47. Interoperable PHP
TS layer in PHP 7
• Global thread specific pointer per binary unit
• Optional special setup to cache TS resource
• No additional tsrm_ls arguments in functions
48. Interoperable PHP
TLS
● __thread qualifier is not a standard
● __declspec(thread) is not a standard
● thread_local is C++11 standard (not in PHP)
● pthread_setspecific, TlsSetValue, etc.