3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function guidv4() { $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } echo guidv4();
Output for 7.1.0
4be38d7f-e50a-4f51-b204-e15a39dc7dbe
Output for 7.0.14
11dd829d-bf5c-41ea-97b6-82f7540aa9a7
Output for 7.0.6
ab85408f-72a3-4050-8790-b4b1f66abc24
Output for 7.0.5
af47a6e9-8a44-47ac-9ab1-36f4dfde0f6e
Output for 7.0.4
efa81a90-8c5b-436e-bc6d-209c4d6f8d10
Output for 7.0.3
29b209d8-58dc-44f7-90dc-c5c173c5c428
Output for 7.0.2
ea52eec2-dd26-4d87-8cad-3291e3c0a6ad
Output for 7.0.1
9a9805b2-1766-4c9a-9af0-d488d364f01b
Output for 7.0.0
8c4eb5e2-756f-46b5-8197-6a62b05f398b
Output for 5.6.28
7b04a3da-8188-44a4-b43d-9c6bb70ba0c5
Output for 5.6.21
6b45845a-a8f7-4c53-b101-09672d514d0e
Output for 5.6.20
3b7a307f-db9d-4f4a-8d82-ef2998dd81c1
Output for 5.6.19
7f0060d4-83a9-4b67-bb98-a57b6dbcd424
Output for 5.6.18
eb0b02c4-e468-42b4-9bb1-f8522468bd3f
Output for 5.6.17
8e9fa73c-b69c-4d1a-a799-59031f3f39ef
Output for 5.6.16
835ecb40-ac67-4e02-b8b6-724719d9f391
Output for 5.6.15
58ef1005-5a10-40ad-a2b4-6280fc066502
Output for 5.6.14
a7a30c27-7a62-4245-ab4f-e678c2f51a3a
Output for 5.6.13
beaa1e8b-cca9-4814-893c-44e62651c444
Output for 5.6.12
1fe6c343-35b6-4126-beff-0b5608fa1a01
Output for 5.6.11
e4e8ba0a-6baa-4641-95c7-c25736105ffc
Output for 5.6.10
63577043-1118-42d5-bb0b-2c3c6b9999ad
Output for 5.6.9
998e2ef9-8e34-48a3-bb38-b4d4af71381e
Output for 5.6.8
17b85987-0da2-4e90-9e8e-0cc09fec4d12
Output for 5.5.35
1a6f92a0-05f3-42db-8ee8-c27950894b7a
Output for 5.5.34
0d76a3fc-1dbd-4be7-b3b6-46dbe5413a4c
Output for 5.5.33
87ae9dbd-7744-4f6b-8e3d-e644d809b099
Output for 5.5.32
7cd209c2-0914-4133-a2e5-8fff6a17e60a
Output for 5.5.31
d51aa370-1d33-4b30-a27f-17028095e36e
Output for 5.5.30
698fd870-0d4b-4de0-9b25-901508cd1ef3
Output for 5.5.29
9e4cbdd5-a0de-4a5b-be52-80998c6e4ccd
Output for 5.5.28
85f2ffcf-cc4e-44ff-b486-10d3c06f26f4
Output for 5.5.27
2fc2caaa-ccce-4dbd-8340-ec6cffbaf5c4
Output for 5.5.26
c7b212e0-457f-488f-b4af-3cababc7a0bf
Output for 5.5.25
7e27a6db-40ed-4752-982b-e6a9ae3d9fde
Output for 5.5.24
e37fee6f-e578-4d05-9ce6-7389bb3758ea
Output for 5.4.45
e9047198-3a5d-4488-8c0f-5927202ad1ea
Output for 5.4.44
b3e79b5a-d510-4211-a902-da01cb57f545
Output for 5.4.43
9bb46fa7-9700-4726-badb-bd6cdb7342c7
Output for 5.4.42
b0f63e6d-2b26-4ae4-a719-5c19ab140655
Output for 5.4.41
9e6f1bdf-71f9-4e11-955b-3695e7ec2b8b
Output for 5.4.40
03d683c6-ec67-4b35-acca-0ec099a5e3c2
Output for 5.4.39
502b3096-2ed1-4116-9725-e449b5f5ed78
Output for 5.4.38
bfa44446-6a15-443c-aeae-676502d259f0
Output for 5.4.37
43a7394a-a101-4a8e-8a26-1a42032b2db6
Output for 5.4.36
7bd752c4-a403-48b4-86de-38b3167707b9
Output for 5.0.0 - 5.4.35
Fatal error: Call to undefined function openssl_random_pseudo_bytes() in /in/G3kL6 on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: openssl_random_pseudo_bytes() in /in/G3kL6 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: openssl_random_pseudo_bytes() in /in/G3kL6 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: openssl_random_pseudo_bytes() in /in/G3kL6 on line 3