One of my php script called setoptions.php is hosted on my new vps server. However, it is not working so I setup php error log as described here and, and I see the following warning repeated in my log file:
PHP Warning: fread(): Length parameter must be greater than 0 in /var/www/html/scripts/setoptions.php on line 311
The line no # 311 is as follows in my php script:
$fname = 'myappconfig.php';
$content = fread($fhandle,filesize($fname));
How do I fix this problem under Unix/Apache/php5 server?
Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | PHP & access to log file |
Time | N/A |
$fname = 'myappconfig.php'; if (is_readable($fname)) { $content = fread($fhandle,filesize($fname)); } else { echo 'The file is not readable.'; }
$fname = 'myappconfig.php'; if (file_exists($fname)) { // do_something like as follows? // $content = fread($fhandle,filesize($fname)); } else { echo "The file $fname does not exist."; }
🐧 1 comment so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Or, you could simply: