Last active
March 16, 2019 15:38
-
-
Save lenivene/78c0b89b590a439c53591afd32a34bd3 to your computer and use it in GitHub Desktop.
Função para verificar se é servidor de teste (localhost)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Verificar servidor | |
* @return null Retorna se tiver erro, se preferir troque para class Exception. | |
* @return true | false Retorna true para localhost e false para servidor | |
* | |
* @version 1.0 | |
* @author Lenivene Bezerra | |
*/ | |
function isServerLocal(){ | |
if( !isset( $_SERVER['SERVER_ADDR'] ) || ! isset( $_SERVER['REMOTE_ADDR'] ) || ! function_exists( 'getcwd' ) ) | |
return null; | |
$isServerLocal = ( | |
$_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR'] | |
&& | |
substr_compare( getcwd(), ":", 1, 1 ) == 0 | |
); | |
return (bool) $isServerLocal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment