This file contains 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
$hash = password_hash("teste", PASSWORD_DEFAULT); | |
$hash = '$2y$10$5JRstzQuO6kd8xeb4fcsyutF7mWwbWw1kX3SpmwcClLfRGp6Y.V2G'; | |
if (password_verify('teste', $hash)) { | |
echo 'Password is valid!'; | |
} else { | |
echo 'Invalid password.'; | |
} |
This file contains 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 | |
function calcula($valor) | |
{ | |
$retorno = []; | |
$divisao = explode('.', $valor); | |
$reais = isset($divisao[0]) ? $divisao[0] : null; | |
$centavos = isset($divisao[1]) ? $divisao[1] : null; | |
if (strlen($reais) <= 6 and !is_null($reais)) { | |
$retorno = array_merge($retorno, calculaReais($reais)); |
This file contains 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
CREATE TABLE `municipal_border` ( | |
`boundary` polygon NOT NULL, | |
`municipalID` int(10) NOT NULL) | |
SET @g = 'POLYGON((22.367582117085913 70.71181669186944, 22.225161442616514 70.65582486840117, 22.20736264867434 70.83229276390898, 22.18701840565626 70.9867880031668, 22.22452581029355 71.0918447658621, 22.382709129816103 70.98884793969023, 22.40112042636022 70.94078275414336, 22.411912121843205 70.7849142238699, 22.367582117085913 70.71181669186944))'; | |
INSERT INTO municipal_border (boundary,municipalID) VALUES (ST_GeomFromText(@g),2) | |
set @p = GeomFromText('POINT(22.4053386588057 70.86240663480157)'); | |
select * FROM municipal_border where ST_Contains(boundary, @p); |
This file contains 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 | |
function dataCompetencia($data) | |
{ | |
$dia = (int) substr($data, 8, 2); | |
$AnoMes = substr($data, 0, 7); | |
if ($dia >= 26) { | |
$date['inicial'] = $AnoMes . '-26'; | |
$date['final'] = date('Y-m', strtotime('+ 1 Month', strtotime($AnoMes))) . '-25'; | |
} else { |
This file contains 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 | |
function __validaCPF($cpf) | |
{ | |
# Retira da string tudo que não estiver entre 0 e 9 | |
$cpf = preg_replace('/[^0-9]/', '', (string) $cpf); | |
# Verifica tamano da string e se todos os digitos são iguais | |
if (strlen($cpf) !== 11 or preg_match('/(\d)\1{10}/', $cpf)) { | |
return false; |
This file contains 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
select | |
* | |
from | |
revan_vendas.teste_localizacao | |
where | |
st_within(point(lg, | |
lt), | |
ST_GeomFromText('Polygon( | |
(-38.498775 -6.197860, | |
-38.498612 -6.197349, |
This file contains 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
#!/usr/bin/php | |
<?php | |
$stdin = fopen('php://stdin', 'r'); | |
echo "Entre com o número de apostas desejadas: " . "\n"; | |
$nrApostas = trim(fgets($stdin)); | |
if (!is_numeric($nrApostas)) { | |
echo "Número inválido"."\n"; | |
} else { |
This file contains 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 | |
$url = "https://fcm.googleapis.com/fcm/send"; | |
$token = "your device token"; | |
$serverKey = 'your server token of FCM project'; | |
$title = "Notification title"; | |
$body = "Hello I am from Your php server"; | |
$notification = array('title' =>$title , 'text' => $body, 'sound' => 'default', 'badge' => '1'); | |
$arrayToSend = array('to' => $token, 'notification' => $notification,'priority'=>'high'); | |
$json = json_encode($arrayToSend); | |
$headers = array(); |