3

Accessing my test.php in a local server environment, and chrome will not load the page.

<?php
  virtual('./database_functions.php');

  echo "<!DOCTYPE html>";
  echo "<body>";
  echo "<p>Hello World"</p>;
  echo "</body>";
  echo "</html>";

?>
Ken Ingram
  • 1,538
  • 5
  • 27
  • 52
  • Why are you using `virtual` and not `include`/`require`? – aynber Sep 11 '17 at 20:46
  • Have you seen this? https://stackoverflow.com/questions/29894154/chrome-neterr-incomplete-chunked-encoding-error – Don't Panic Sep 11 '17 at 20:50
  • Dreamweaver put it in the file. It's for relative referencing so I kept it? Can you tell me why you are asking? Why would I *not* use it? – Ken Ingram Sep 11 '17 at 20:54
  • 1
    Oy, another reason to not like Dreamweaver. [Here is the documentation on virtual](http://php.net/manual/en/function.virtual.php), basically it's making an apache call, and not inserting the unprocessed code you need into your script. You need to use either [include](http://php.net/manual/en/function.include.php) or [require](http://php.net/manual/en/function.require.php) (I'd personally go for `require_once`), which would put the PHP code in exactly as you created it. – aynber Sep 11 '17 at 20:57
  • Ok. That makes sense. Apparently Dreamweaver uses it for relative referencing depending on site configuration. I've gone back to using raw text writing my HTML and PHP because Dreamweaver is such a bloated POS. – Ken Ingram Sep 11 '17 at 20:59

1 Answers1

0

Running the script from command line php I get:

PHP Fatal error:  Call to undefined function virtual() in /var/www/test.php on line 2

This simply illustrates a new question.

Google searching reveals that include/require/require_once is recommended, however, I'd like to understand why virtual is being problematic.

It's not so much getting the right answer as understanding why virtual() is being problematic.

EDIT: Blame Dreamweaver. Explained by @aynber

Ken Ingram
  • 1,538
  • 5
  • 27
  • 52