0

I am getting this error in php that says

A non-numeric value encountered in file.php on line 180

Here is my code

$path = $pth + '/logo.png';
if(file_exists($path)){
    echo 'yes';
}
else{
    echo 'no';
}

I also got this error with other file operations also like copy() and mkdir(). Removing . and / makes them work fine.

Any way to solve this error. Thanks in advance :)

Uncias
  • 82
  • 8

2 Answers2

2

Use this

$path = $pth . '/logo.png';
if(file_exists($path)){
 echo 'yes';
}
 else{
  echo 'no';
}
The IRF
  • 470
  • 3
  • 13
2

The concatenation operator ('.'), which returns the concatenation of its right and left arguments. Reference

$path = $pth.'/logo.png';
if(file_exists($path)){
    echo 'yes';
}
else{
    echo 'no';
}
ORHAN ERDAY
  • 1,020
  • 8
  • 31
  • I knew that. Seems like should stop python for some days – Uncias Nov 13 '20 at 14:22
  • I use PHP and JavaScript for my project, sometimes I have the same problem. We all make mistakes. you can solve your problem as soon as possible by practicing. – ORHAN ERDAY Nov 13 '20 at 14:53