PHP

PHP

PHP: Gerando nome de arquivo aleatório

Função rand() <? function pegaExtensao($arquivo){ $ext = explode(’.’,$arquivo); $ext = array_reverse($ext); return ".".$ext[0]; } function pegaSomenteNome($arquivo){ $nome = pathinfo($arquivo); return

MySQL, PHP

PHP-MySQL: Trabalhando com função

<? function quantidade(){ $select = "SELECT quantidade FROM qtd_noticias"; $rs = mysql_query($select); while($row = mysql_fetch_array($rs)){ $qtd = $row[’quantidade’]; return $qtd;

MySQL, PHP

PHP-MySQL: Descobrindo a versão do MySQL

<? $result = mysql_query(’SELECT VERSION()’) or die(’Query failed: ‘ . mysql_error()); $mysql_version = mysql_fetch_array($result, MYSQL_ASSOC); echo $mysql_version[’VERSION()’]; ?><? $result =

JavaScript, PHP

PHP-JavaScript: header(Location…) x location.href

PHP: Utilizando “header(location…)” <? header("Location:index.php"); ?><? header("Location:index.php"); ?> PHP: Utilizando “header(location…)” com parâmetros <? header("Location:index.php?mensagem=OK"); ?><? header("Location:index.php?mensagem=OK"); ?> JavaScript: Utilizando

PHP

PHP: Lendo um array

<? $numArray = array(’1′, ‘2’, ‘3’, ‘4’);   foreach($numArray as $valor) { echo($valor .’ ‘); } ?><? $numArray = array(‘1’,

Rolar para cima