Reading a File
<PRE><? readfile("/proc/cpuinfo");?></PRE>
|
|
Output:
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 44
model name : Intel(R) Xeon(R) CPU X5650 @ 2.67GHz
stepping : 2
cpu MHz : 2659.999
cache size : 12288 KB
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up ida nonstop_tsc arat pni ssse3 cx16 sse4_1 sse4_2 popcnt lahf_lm
bogomips : 5319.99
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: [8]
<?
$file = fopen("sample.txt", "r");
while (!feof($file)) { echo fgets($file, 1024), "<BR>"; } ?>
|
|
Reading from a URL
<? $file = fopen("http://www.php.net/file.txt", "r"); ?>
|
|
Writing to a file
<? $file = fopen("agent.log", "a"); fputs($file, $HTTP_USER_AGENT."\n"); ?>
|
|