3v4l.org

run code in 300+ PHP versions simultaneously
<?php $image = 'image/testing.jpg'; $url = 'http://testing.com'; $image_parts = parse_url($image); $url_parts = parse_url($url); // check to see if the image has a path of its own if (dirname($image_parts['path']) == '.') { $image_path = dirname($url_parts['path']) . DS . $image_parts['path']; } else { $image_path = $image_parts['path']; } if (empty($image_parts['host'])) { $image_location = sprintf('%s://%s/%s/%s', $url_parts['scheme'], $url_parts['host'], dirname($url_parts['path']), $image_path); } else { $image_location = $image; } var_dump($image_location);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "path" in /in/75Q4Q on line 17 Deprecated: dirname(): Passing null to parameter #1 ($path) of type string is deprecated in /in/75Q4Q on line 17 string(37) "http://testing.com//image/testing.jpg"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.08 ms | 401 KiB | 8 Q