Abrir uma página ao sair de outra no JavaScript
<script>
function outra() {
window.open(‘paginadois.html’);
}
</script>
<body onunload=”outra();”>
<script>
function outra() {
window.open(‘paginadois.html’);
}
</script>
<body onunload=”outra();”>
<script language=”JavaScript”>
<!–
function trava() {
alert(‘Coloque sua mensagem aqui !’);
}
document.onkeydown=trava;
// –>
</script>
<?php
// Trazer conteúdo de arquivo ou de página para string
// Define a context for HTTP.
$filename = '/caminho/para/qualquer.txt'; if (file_exists($filename)) { print "O arquivo $filename existe"; } else { print "O arquivo $filename não existe"; }
mkdir (“/path/to/my/dir”, 0700);
is_file — Diz se o arquivo é um arquivo comum (não é diretório)
<?php rename("teste.txt", teste2.txt"); ?>
<?php function deleteDirectory($dirname,$only_empty=false) { if (!is_dir($dirname)) return false; $dscan = array(realpath($dirname)); $darr = array(); while (!empty($dscan)) { $dcur = array_pop($dscan); $darr[] = $dcur; if ($d=opendir($dcur)) { while ($f=readdir($d)) { if ($f=='.' || $f=='..') continue; $f=$dcur.'/'.$f; if (is_dir($f)) $dscan[] = $f; else unlink($f); } closedir($d); } } $i_until = ($only_empty)? 1 : 0; for ($i=count($darr)-1; $i>=$i_until; $i--) { echo "\nDeleting '".$darr[$i]."' ... "; if (rmdir($darr[$i])) echo "ok"; else echo "FAIL"; } return (($only_empty)? (count(scandir)<=2) : (!is_dir($dirname))); } Consulte mais informação
<?php // Lê e imprime todo o conteúdo de um arquivo CSV $row = 1; $handle = fopen ("test.csv","r"); while ($data = fgetcsv ($handle, 1000, ",")) { $num = count ($data); print "<p> $num campos na linha $row: <br>"; $row++; for ($c=0; $c < $num; $c++) { print $data[$c] . "<br>"; } } fclose ($handle); ?>
<?
function dir_size( $dir ) {
if( !$dir or !is_dir( $dir ) ) { return 0; }
<?php
// ESPAÇO LIVRE NO DISCO
// $df contém o número de bytes disponível em “/”
<?php
function getDirectorySize($path) {
$totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $file; if ($file != '.' && $file != '..' && !is_link ($nextpath)) { if (is_dir ($nextpath)) { $dircount++; $result = getDirectorySize($nextpath); $totalsize += $result['size']; $totalcount += $result['count']; $dircount += $result['dircount']; } elseif (is_file ($nextpath)) { $totalsize += filesize ($nextpath); $totalcount++; } } } } closedir ($handle); $total['size'] = $totalsize; $total['count'] = $totalcount; $total['dircount'] = $dircount; return $total;
<?php
// ESPAÇO TOTAL NO DISCO
$diretorio=”c:/”;
print disk_total_space($diretorio);
print ” “;
?>
<?php print '<br>'; // TESTAR SE ARQUIVO É UM ARQUIVO COMUM OU SE É DIRETÓRIO $filename = 'teste2.php'; Consulte mais informação
<?php print '<br>'; // TESTAR SE ARQUIVO EXISTE $filename = 'teste2.php'; if (file_exists($filename)) { echo "O arquivo $filename existe"; }else{ echo "O arquivo $filename não existe"; } ?>
<?php
if (is_writable($filename)) { echo 'O arquivo permite escrita'; }else { echo 'O arquivo não permite escrita'; } ?>