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 | |
function limpar_texto($str){ | |
return preg_replace("/[^0-9]/", "", $str); | |
} | |
// Exemplo de Utilização | |
echo limpar_texto('Olá 1456Mundo!'); | |
// vai retornar 1456 | |
?> |
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 | |
function deletar($pasta){ | |
$iterator = new RecursiveDirectoryIterator($pasta,FilesystemIterator::SKIP_DOTS); | |
$rec_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST); | |
foreach($rec_iterator as $file){ | |
$file->isFile() ? unlink($file->getPathname()) : rmdir($file->getPathname()); | |
} |
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 | |
function get_endereco($cep){ | |
// formatar o cep removendo caracteres nao numericos | |
$cep = preg_replace("/[^0-9]/", "", $cep); | |
$url = "http://viacep.com.br/ws/$cep/xml/"; | |
$xml = simplexml_load_file($url); |
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
<div itemscope itemtype="http://schema.org/Product"> | |
<a itemprop="url" href="url-do-produto"> | |
<div itemprop="name"> | |
<strong>Nome do Produto</strong> | |
</div> | |
</a> | |
<div itemprop="description">Descricao do Produto</div> |
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 | |
include("conexao.php"); // caminho do seu arquivo de conexão ao banco de dados $consulta = "SELECT * FROM usuario"; $con = $mysqli->query($consulta) or die($mysqli->error); | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Tutorial</title> | |
</head> |
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 | |
$host = "localhost"; | |
$usuario = "USUARIO"; | |
$senha = "SENHA"; | |
$bd = "BANCODEDADOS"; | |
$mysqli = new mysqli($host, $usuario, $senha, $bd); | |
if($mysqli->connect_errno) |
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 | |
include("conexao.php"); | |
$msg = false; | |
if(isset($_FILES['arquivo'])){ | |
$extensao = strtolower(substr($_FILES['arquivo']['name'], -4)); //pega a extensao do arquivo | |
$novo_nome = md5(time()) . $extensao; //define o nome do arquivo |
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 | |
$hostname = "localhost"; | |
$bancodedados = "bancodedados"; | |
$usuario = "usuario"; | |
$senha = "senha"; | |
$mysqli = new mysqli($hostname, $usuario, $senha, $bancodedados); | |
if ($mysqli->connect_errno) { | |
echo "Falha ao conectar: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Sua Página</title> | |
<link href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" rel="stylesheet"> | |
</head> | |
<body> |
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
-- phpMyAdmin SQL Dump | |
-- version 5.0.2 | |
-- https://www.phpmyadmin.net/ | |
-- | |
-- Host: 127.0.0.1:3306 | |
-- Tempo de geração: 09-Set-2022 às 11:08 | |
-- Versão do servidor: 5.7.31 | |
-- versão do PHP: 7.3.21 | |
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; |