-3

Hi I'm a Amateur programer and I need help for my web's programer subject. I'm trying to link this js but on the page show me this on the top Warning: file_get_contents(script404.js): Failed to open stream: No such file or directory in C:\xampp\apps\wordpress\htdocs\wp-content\themes\villanueva-s_theme-brown_nights-\404.php on line 58

<?php
   $script = file_get_contents('script404.js');
   echo "<script>".$script."</script>";
?>

2 Answers2

0

You can just use:

echo "<script src=\"script404.js\"></script>";

Or, you should point to the right directory, like:

   $script = file_get_contents('C:/path/to/script404.js');
   echo "<script>".$script."</script>";

Or, I wouldn't advice you to do this, but if it is in the same directory:

   $script = file_get_contents('./script404.js');
   echo "<script>".$script."</script>";
Example person
  • 3,198
  • 3
  • 18
  • 45
0

You must have an invalid path.

You could use __DIR__.'/script404.js' if this file is in the same folder as script you running.

See Evert's answer in Why include __DIR__ in the require_once?

LordF
  • 407
  • 5
  • 18