3v4l.org

run code in 300+ PHP versions simultaneously
function convertLHS( $lhs ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$lhs ); $num = count($eles); if ( $num == 1) $retval = "S=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num == 2) $retval = "S=" . strtoupper($eles[1]) . $x400Delimiter . "G=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num > 2) $retval = "S=" . strtoupper($eles[$num-1]) . $x400Delimiter . getInitials($lhs) . "G=" . strtoupper($eles[0]) . $x400Delimiter; return $retval ; } // domain element // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function convertSubDomain( $domain ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$domain ); $num = count($eles); if ( $num == 1) return "OU=" . strtoupper($eles[0]) . $x400Delimiter; } // sort initials if they exist // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function getInitials($lhs) { global $x400Delimiter; $retval = "I="; $eles = explode('.',$lhs ); $num = count($eles); for ($i=1;$i<$num-1;$i++) { $subStr = $eles[$i]; // test if multiple if (strlen($subStr) > 1) { $arr = str_split($subStr); $subStr = implode('.',$arr); } $retval .= strtoupper($subStr) . '.'; } return rtrim($retval,'.' ). $x400Delimiter; } // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function normaliseX400($x400) { return $x400; } // get the posted search string $searchString = $_GET['searchStr']; $x400 = ""; try { global $x400Prefix; global $x400Postfix; $lhsrhs = explode("@",$searchString); $emailComps['domain'] = $lhsrhs[1]; $emailComps['name'] = $lhsrhs[0]; $emailComps['subdomain'] = explode(".x.gsi.gov.uk",$emailComps['domain'] )[0]; $x400 = normaliseX400 ( convertSubdomain($emailComps['subdomain'] ) . convertLHS($emailComps['name']) ); $x400 = $x400Prefix . $x400 . $x400Postfix; } catch (Exception $e) { throw new Exception( 'Failed to analyse email ['.$searchString.'] ', $e); } //print_r($emailComps); // output the basic html ?> <p>Found a [ <?php echo strtoupper($emailComps['subdomain']); ?> ] confidential other government department address in ( <?php echo $searchString ; ?> ).</p> <p>Click here to email: <a href= "mailto:%3C?php%20echo%20urlencode($x400);%20?%3E"> X.400 address for <?php echo $emailComps['name'] ?> </a><br></p> <address> <?php echo $x400 ?> </address>
Output for git.master, git.master_jit
function convertLHS( $lhs ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$lhs ); $num = count($eles); if ( $num == 1) $retval = "S=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num == 2) $retval = "S=" . strtoupper($eles[1]) . $x400Delimiter . "G=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num > 2) $retval = "S=" . strtoupper($eles[$num-1]) . $x400Delimiter . getInitials($lhs) . "G=" . strtoupper($eles[0]) . $x400Delimiter; return $retval ; } // domain element // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function convertSubDomain( $domain ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$domain ); $num = count($eles); if ( $num == 1) return "OU=" . strtoupper($eles[0]) . $x400Delimiter; } // sort initials if they exist // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function getInitials($lhs) { global $x400Delimiter; $retval = "I="; $eles = explode('.',$lhs ); $num = count($eles); for ($i=1;$i<$num-1;$i++) { $subStr = $eles[$i]; // test if multiple if (strlen($subStr) > 1) { $arr = str_split($subStr); $subStr = implode('.',$arr); } $retval .= strtoupper($subStr) . '.'; } return rtrim($retval,'.' ). $x400Delimiter; } // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function normaliseX400($x400) { return $x400; } // get the posted search string $searchString = $_GET['searchStr']; $x400 = ""; try { global $x400Prefix; global $x400Postfix; $lhsrhs = explode("@",$searchString); $emailComps['domain'] = $lhsrhs[1]; $emailComps['name'] = $lhsrhs[0]; $emailComps['subdomain'] = explode(".x.gsi.gov.uk",$emailComps['domain'] )[0]; $x400 = normaliseX400 ( convertSubdomain($emailComps['subdomain'] ) . convertLHS($emailComps['name']) ); $x400 = $x400Prefix . $x400 . $x400Postfix; } catch (Exception $e) { throw new Exception( 'Failed to analyse email ['.$searchString.'] ', $e); } //print_r($emailComps); // output the basic html ?> <p>Found a [ Warning: Undefined variable $emailComps in /in/9OUdg on line 129 Warning: Trying to access array offset on value of type null in /in/9OUdg on line 129 Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /in/9OUdg on line 129 ] confidential other government department address in ( Warning: Undefined variable $searchString in /in/9OUdg on line 131 ).</p> <p>Click here to email: <a href= "mailto:%3C?php%20echo%20urlencode($x400);%20?%3E"> X.400 address for Warning: Undefined variable $emailComps in /in/9OUdg on line 137 Warning: Trying to access array offset on value of type null in /in/9OUdg on line 137 </a><br></p> <address> Warning: Undefined variable $x400 in /in/9OUdg on line 140 </address>
Output for rfc.property-hooks
function convertLHS( $lhs ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$lhs ); $num = count($eles); if ( $num == 1) $retval = "S=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num == 2) $retval = "S=" . strtoupper($eles[1]) . $x400Delimiter . "G=" . strtoupper($eles[0]) . $x400Delimiter; if ( $num > 2) $retval = "S=" . strtoupper($eles[$num-1]) . $x400Delimiter . getInitials($lhs) . "G=" . strtoupper($eles[0]) . $x400Delimiter; return $retval ; } // domain element // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function convertSubDomain( $domain ) { global $x400Delimiter; $retval = ""; $eles = explode('.',$domain ); $num = count($eles); if ( $num == 1) return "OU=" . strtoupper($eles[0]) . $x400Delimiter; } // sort initials if they exist // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function getInitials($lhs) { global $x400Delimiter; $retval = "I="; $eles = explode('.',$lhs ); $num = count($eles); for ($i=1;$i<$num-1;$i++) { $subStr = $eles[$i]; // test if multiple if (strlen($subStr) > 1) { $arr = str_split($subStr); $subStr = implode('.',$arr); } $retval .= strtoupper($subStr) . '.'; } return rtrim($retval,'.' ). $x400Delimiter; } // --------------------------------------- // Function Declaration // ---------------------------------------- // name: // does: // accepts: // returns: function normaliseX400($x400) { return $x400; } // get the posted search string $searchString = $_GET['searchStr']; $x400 = ""; try { global $x400Prefix; global $x400Postfix; $lhsrhs = explode("@",$searchString); $emailComps['domain'] = $lhsrhs[1]; $emailComps['name'] = $lhsrhs[0]; $emailComps['subdomain'] = explode(".x.gsi.gov.uk",$emailComps['domain'] )[0]; $x400 = normaliseX400 ( convertSubdomain($emailComps['subdomain'] ) . convertLHS($emailComps['name']) ); $x400 = $x400Prefix . $x400 . $x400Postfix; } catch (Exception $e) { throw new Exception( 'Failed to analyse email ['.$searchString.'] ', $e); } //print_r($emailComps); // output the basic html ?> <p>Found a [ Warning: Undefined variable $emailComps in /in/9OUdg on line 129 Warning: Trying to access array offset on null in /in/9OUdg on line 129 Deprecated: strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated in /in/9OUdg on line 129 ] confidential other government department address in ( Warning: Undefined variable $searchString in /in/9OUdg on line 131 ).</p> <p>Click here to email: <a href= "mailto:%3C?php%20echo%20urlencode($x400);%20?%3E"> X.400 address for Warning: Undefined variable $emailComps in /in/9OUdg on line 137 Warning: Trying to access array offset on null in /in/9OUdg on line 137 </a><br></p> <address> Warning: Undefined variable $x400 in /in/9OUdg on line 140 </address>

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:
48.3 ms | 408 KiB | 8 Q