<?php
$file_reader = fopen("sample_text.txt", "r");
$content = fread($file_reader, 4);
echo $content;
?>
Output:
This
<?php
$file_reader = fopen("sample_text.txt", "r");
$content = fread($file_reader, 4);
echo $content;
?>
Output:
This
<?php
if (ini_get("mbstring.func_overload") & 2 != 0) {
echo "ini_get(\"mbstring.func_overload\")" . "<br/>";
}
if (function_exists('mb_substr')) {
echo "mb_substr exists";
}
?>
<?php
$file_reader = fopen("sample_text.txt", "r");
while(!feof($file_reader)) {
echo fgets($file_reader) . "<br/>";
}
?>
sample_text.txt:
This is php file reading exampleOutput:
This is php file reading example
<?php
$color = array("blue", "red", "green", array("light gray", "dark gray"), "yellow" => array("lemon", "normal"));
echo count($color) . "<br/>";
echo count($color, 1);
?>
Output:
5 9
<?php
$colorStr = "blue:red:green:yellow";
$colors = explode(":", $colorStr, 3);
var_dump($colors);
$colors = explode(":", $colorStr, 4);
echo "<br/>";
var_dump($colors);
?>
Output:
array(3) { [0]=> string(4) "blue" [1]=> string(3) "red" [2]=> string(12) "green:yellow" }
array(4) { [0]=> string(4) "blue" [1]=> string(3) "red" [2]=> string(5) "green" [3]=> string(6) "yellow" }
$x = <<<THE_END PHP stands for "PHP: Hypertext Preprocessor". The acronym "PHP" is therefore, usually referre...