3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $links = array( "product.php?shopprodid=62&variantid=152" => "link, "index.php?pageid=2" => "https://storksak.com/changing-bags/olivia" ); foreach ($links as $url => $tourl){ $parsed_url = parse_url($url); $query = isset($parsed_url['query']) ? $parsed_url['query'] : ''; parse_str($query,$parts); if ($parts["shopprodid"] && $parts["variantid"]){ echo 'RewriteCond %{QUERY_STRING} ^shopprodid='.$parts["shopprodid"].'&variantid='.$parts["variantid"].'$'."\n"; echo 'RewriteRule ^product.php$ '.$tourl.' [R=301]'; } elseif ($parts["pageid"]){ echo 'RewriteCond %{QUERY_STRING} ^pageid='.$parts["pageid"].'$'."\n"; echo 'RewriteRule ^product.php$ '.$tourl.' [R=301]'; } elseif ($parts["shopcatid"]){ echo 'RewriteCond %{QUERY_STRING} ^shopcatid='.$parts["shopcatid"].'$'."\n"; echo 'RewriteRule ^product.php$ '.$tourl.' [R=301]'; } }
based on nDppW
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.1.6
Parse error: syntax error, unexpected 'index' (T_STRING), expecting ')' in /in/hrRuK on line 5
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_STRING, expecting ')' in /in/hrRuK:5 Stack trace: #0 {main}
Process exited with code 255.