3v4l.org

run code in 300+ PHP versions simultaneously
<?php function guidv4() { $data = file_get_contents('/dev/urandom', false, null, 0, 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 8.3.0 - 8.3.6
Warning: file_get_contents(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/tmp:/in:/etc) in /in/fVj1e on line 3 Warning: file_get_contents(/dev/urandom): Failed to open stream: Operation not permitted in /in/fVj1e on line 3 Warning: Trying to access array offset on false in /in/fVj1e on line 4 Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /in/fVj1e on line 4 Deprecated: Automatic conversion of false to array is deprecated in /in/fVj1e on line 4 Warning: Undefined array key 8 in /in/fVj1e on line 5 Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /in/fVj1e on line 5 Fatal error: Uncaught TypeError: bin2hex(): Argument #1 ($string) must be of type string, array given in /in/fVj1e:6 Stack trace: #0 /in/fVj1e(6): bin2hex(Array) #1 /in/fVj1e(9): guidv4() #2 {main} thrown in /in/fVj1e on line 6
Process exited with code 255.
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: file_get_contents(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/tmp:/in:/etc) in /in/fVj1e on line 3 Warning: file_get_contents(/dev/urandom): Failed to open stream: Operation not permitted in /in/fVj1e on line 3 Warning: Trying to access array offset on value of type bool in /in/fVj1e on line 4 Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /in/fVj1e on line 4 Deprecated: Automatic conversion of false to array is deprecated in /in/fVj1e on line 4 Warning: Undefined array key 8 in /in/fVj1e on line 5 Deprecated: ord(): Passing null to parameter #1 ($character) of type string is deprecated in /in/fVj1e on line 5 Fatal error: Uncaught TypeError: bin2hex(): Argument #1 ($string) must be of type string, array given in /in/fVj1e:6 Stack trace: #0 /in/fVj1e(6): bin2hex(Array) #1 /in/fVj1e(9): guidv4() #2 {main} thrown in /in/fVj1e on line 6
Process exited with code 255.
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
Warning: file_get_contents(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/tmp:/in:/etc) in /in/fVj1e on line 3 Warning: file_get_contents(/dev/urandom): Failed to open stream: Operation not permitted in /in/fVj1e on line 3 Warning: Trying to access array offset on value of type bool in /in/fVj1e on line 4 Warning: Undefined array key 8 in /in/fVj1e on line 5 Fatal error: Uncaught TypeError: bin2hex(): Argument #1 ($string) must be of type string, array given in /in/fVj1e:6 Stack trace: #0 /in/fVj1e(6): bin2hex(Array) #1 /in/fVj1e(9): guidv4() #2 {main} thrown in /in/fVj1e on line 6
Process exited with code 255.
Output for 8.0.13
fe47a205-ab6b-46a3-b711-0ee3addfca25
Output for 7.4.33
be48b053-7947-4252-b33a-5b85c08abef8
Output for 7.4.0 - 7.4.32
Warning: file_get_contents(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/tmp:/in:/etc) in /in/fVj1e on line 3 Warning: file_get_contents(/dev/urandom): failed to open stream: Operation not permitted in /in/fVj1e on line 3 Notice: Trying to access array offset on value of type bool in /in/fVj1e on line 4 Notice: Undefined offset: 8 in /in/fVj1e on line 5 Warning: bin2hex() expects parameter 1 to be string, array given in /in/fVj1e on line 6 Warning: vsprintf(): Too few arguments in /in/fVj1e on line 6
Output for 7.3.33
8941678c-4aa0-428b-a70f-39b1d59e1765
Output for 7.3.32
da9ffdda-69f7-4adc-a5d3-65cea1ac9b1d
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Warning: file_get_contents(): open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s): (/tmp:/in:/etc) in /in/fVj1e on line 3 Warning: file_get_contents(/dev/urandom): failed to open stream: Operation not permitted in /in/fVj1e on line 3 Notice: Undefined offset: 8 in /in/fVj1e on line 5 Warning: bin2hex() expects parameter 1 to be string, array given in /in/fVj1e on line 6 Warning: vsprintf(): Too few arguments in /in/fVj1e on line 6
Output for 5.4.45
dcf15dae-4474-46c9-ab4c-11fa074b9c31
Output for 5.4.44
035c07e0-3b25-4863-bb84-b41697d7e30f
Output for 5.4.43
c3469128-d3a4-49ce-89b7-eab05588cfcf
Output for 5.4.42
d995ffec-e1d4-4579-87b8-ac0b05b706bf
Output for 5.4.41
d41de003-c894-4f95-9983-a55f75fa7f08
Output for 5.4.40
078d1a8b-c89b-44c5-9cf8-4d33a1374aec
Output for 5.4.39
9848a7b9-58c7-4a58-8c82-6342d4719253
Output for 5.4.38
bc1534b3-a7f0-4fc3-86d8-280dfedf28b3
Output for 5.4.37
6199e60e-eeb3-4ea0-ba43-a9b87f6fd43a
Output for 5.4.36
d3861152-83b0-44cf-957a-3a2cdb6f7ba2
Output for 5.4.35
de8c05e6-e073-411a-bd81-13b03f8fedf6
Output for 5.4.34
79e331cf-614d-4cd5-85f7-b264ecb2db4f
Output for 5.4.33
fd42f7a3-b1e1-443e-a131-f15baa8cb5f6
Output for 5.4.32
31f81300-e03b-4d4a-97d9-8827270fe801
Output for 5.4.31
432a6ac8-600f-4820-8f46-a32bbc4cfe79
Output for 5.4.30
1543b25d-f4a7-40b2-bbdc-c3c429144bb8
Output for 5.4.29
fa019a04-8014-43e5-a963-997a09e78d93
Output for 5.4.28
eb93991c-36a0-444f-99c9-bf00496bf4ab
Output for 5.4.27
e6233dbd-f91d-48cc-83df-497ce2958818
Output for 5.4.26
715d9c34-dadf-4468-91e3-ba5734e7988e
Output for 5.4.25
5443a609-46bf-45c4-ae86-0f4f7dfb69ba
Output for 5.4.24
b8e46516-213c-4fa3-beee-7423080ee48a
Output for 5.4.23
006b9773-d21d-4482-be05-a43da43e84eb
Output for 5.4.22
b157ac1c-a877-4cda-a328-221b8b3300ba
Output for 5.4.21
cf92e939-4264-4716-8585-480f448794ae
Output for 5.4.20
f732ed35-ba58-4f7f-af0f-b666fb4940ba
Output for 5.4.19
4e09fc6f-6744-4cb3-9343-b808cb0e07fa
Output for 5.4.18
2f916599-808e-4943-b87f-325d15417103
Output for 5.4.17
8b7b7707-a33b-4030-a519-d7de5fd81b82
Output for 5.4.16
898d7363-e074-443a-9244-4bb828a3037d
Output for 5.4.15
8caa758d-c014-47ef-acb8-bf07821c3f3b
Output for 5.4.14
5eec3584-5708-4c41-b26a-cc1991dd4649
Output for 5.4.13
272ab23a-41bc-4158-944b-142f7fc1f588
Output for 5.4.12
0bc9586d-c0c7-4703-981a-1e261c3896e7
Output for 5.4.11
2d2806e6-5cee-4c21-bde4-65cf714636be
Output for 5.4.10
bb4c7f56-2c7a-4303-ac07-64a687185a24
Output for 5.4.9
b7304abd-03d7-428b-9dc7-3bd4a06c365a
Output for 5.4.8
ac7e3c70-7875-4cc8-90a6-d4f407045ffa
Output for 5.4.7
7ff8a155-8ed8-4435-adc6-93c8333749f0
Output for 5.4.6
07ca36d9-ff92-4ef3-8980-12253b276ad2
Output for 5.4.5
24729dee-8df3-4ef1-816c-6eb2bf2c3c8b
Output for 5.4.4
d8f0a1c1-694c-4dca-be09-b0be92ce4544
Output for 5.4.3
c4297475-e28a-433f-8686-b95e38eb3bd0
Output for 5.4.2
af4973ff-35be-45d0-8871-222c9bcd5beb
Output for 5.4.1
7c0c1d94-ed7a-47a8-b527-3903eea0ea60
Output for 5.4.0
3b918426-350e-4287-9883-16a51ef9b762
Output for 5.3.29
f7203ad1-9662-44d3-bfd7-44cfbcdc0e53
Output for 5.3.28
d213c3bd-16fd-4b15-9720-0c734b3c26a9
Output for 5.3.27
c8108cec-9fa7-44ab-9f64-95e1e399f4ef
Output for 5.3.26
568e6fcd-5bcf-49f6-a989-ffc20dba5441
Output for 5.3.25
faead083-921a-4797-81a0-a10ae2558789
Output for 5.3.24
a2dea8d2-bb21-40a9-900c-457cbe9a5324
Output for 5.3.23
a0428417-da3a-4723-855d-3841b0e7ec11
Output for 5.3.22
09a12729-d92d-49cf-ac3a-1851c26fcc5c
Output for 5.3.21
32ec1da4-ffd9-4c92-86ea-7f82b6cdd05e
Output for 5.3.20
f4ee57b3-c694-434c-98cc-021a745d9f15
Output for 5.3.19
b02575c5-9cdb-4a07-b859-8b5ec3c6e665
Output for 5.3.18
cf4ab5c1-1d64-483f-864e-bb25626d8082
Output for 5.3.17
6bfe6c27-de14-42d2-8454-5ce9ba42f7c2
Output for 5.3.16
7476e881-21d2-4a6b-bc4b-7478e76fda33
Output for 5.3.15
739a6bef-22e1-45d2-9896-3bec551e37ad
Output for 5.3.14
0b2ff068-6624-4420-840d-3631520b8dc0
Output for 5.3.13
731346b4-e372-46d1-8d53-eab48b8f65a4
Output for 5.3.12
4bfd44a2-aff8-4430-9c8f-23c9c8921400
Output for 5.3.11
cc47cce4-614c-4937-8e51-7642fda9b2cc
Output for 5.3.10
0afee6e6-c5d9-4efd-a7a7-5b80849af53e
Output for 5.3.9
8901d511-2c45-42ae-bc5b-ebd951dd1a38
Output for 5.3.8
a13d6e6c-ed31-4ec6-9a8b-55e4c2098e1d
Output for 5.3.7
54bfb1df-41f0-4bab-b5a6-8ad21cfded6a
Output for 5.3.6
e9af8645-8a8a-453e-89c8-84f8b1b70df6
Output for 5.3.5
4900865d-3fbe-4257-9dc5-f255fc57dec3
Output for 5.3.4
829a7c13-8c28-46b7-9e62-867b958189f3
Output for 5.3.3
07d975c8-1ac7-4a87-85d6-62bd04e2821a
Output for 5.3.2
3f4fb8f3-631e-4d86-8d23-6efdbb9d7b39
Output for 5.3.1
7f89968c-9003-4686-ad33-fcc6b18dc1c9
Output for 5.3.0
25d50172-e73f-4e75-b063-768009c07239
Output for 5.2.17
bb8c12bd-6579-43b7-9a27-46166f5ce0c1
Output for 5.2.16
c8f56b31-e87a-46c7-b647-74d29aa38080
Output for 5.2.15
58d77e3f-e8f8-4ebf-8657-096dae29613f
Output for 5.2.14
b2e599bb-2776-46da-a2a0-69c6d0c334c8
Output for 5.2.13
e0af14ec-7381-44ba-b509-e859d5cab75f
Output for 5.2.12
cfcd9bdc-719e-42d5-a86e-f54de8653581
Output for 5.2.11
ad690864-8ee6-46fe-a2d7-804ace90d664
Output for 5.2.10
b2dab714-a4fa-4cf1-bb32-40a3fe062a40
Output for 5.2.9
5520bcdb-8870-410e-aae5-9b2f7c104564
Output for 5.2.8
1db63b45-4436-4200-b205-1aaa589de0b6
Output for 5.2.7
c553efc7-10ad-45db-8a5a-8f23d0cf0220
Output for 5.2.6
cec852e0-e4d5-4928-9431-00f974a93771
Output for 5.2.5
e3310b9c-d2bd-410f-9a35-2064872de45f
Output for 5.2.4
4b4d4797-fc0d-4bcf-b01f-261a5099db01
Output for 5.2.3
df2e8c82-08c7-4684-a26e-16b82efd07bb
Output for 5.2.2
f8bfbcaa-d21c-48ed-9313-5ca11aee5006
Output for 5.2.1
b69e8309-93e4-4400-a00c-bbf1b3b5bb8b
Output for 5.2.0
7bdb6b01-420c-4280-b933-d0a2efd90471
Output for 5.1.6
ff608a47-af44-4b4a-a994-42b05cd8a5d2
Output for 5.1.5
3cfed555-dd18-45df-9f16-37c5b08ed84b
Output for 5.1.4
9c8d74e5-beb8-4a4d-906a-675b34c6592f
Output for 5.1.3
f06604b7-4dc8-4126-b106-c8541d00b6eb
Output for 5.1.2
a9dc6941-ec3a-4073-b1ef-d8fc4003bcda
Output for 5.1.1
076fabea-40d1-4341-b1b3-eb6cc7f11f6b
Output for 5.1.0
8df62bb4-058c-4774-b3ff-9b94a30c6d53
Output for 5.0.0 - 5.0.5
Warning: file_get_contents() expects at most 3 parameters, 5 given in /in/fVj1e on line 3 Notice: Undefined offset: 8 in /in/fVj1e on line 5 Notice: Array to string conversion in /in/fVj1e on line 6 Warning: vsprintf(): Too few arguments in /in/fVj1e on line 6
Output for 4.4.5 - 4.4.9
Warning: file_get_contents() expects at most 2 parameters, 5 given in /in/fVj1e on line 3 Notice: Undefined offset: 8 in /in/fVj1e on line 5 Fatal error: Call to undefined function: str_split() in /in/fVj1e on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Warning: file_get_contents() expects at most 2 parameters, 5 given in /in/fVj1e on line 3 Notice: Undefined offset: 8 in /in/fVj1e on line 5 Fatal error: Call to undefined function: str_split() in /in/fVj1e on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: file_get_contents() expects at most 2 parameters, 5 given in /in/fVj1e on line 3 Notice: Undefined offset: 8 in /in/fVj1e on line 5 Fatal error: Call to undefined function: str_split() in /in/fVj1e on line 6

preferences:
301.23 ms | 402 KiB | 459 Q