A
Anonymous
Guest
Hello PHP Codes,
I am having problem with testing example codes from the videos i am watching in youtube (sorry, just a hobby here for fun).
All of my php tutorial files are located on
"/opt/lampp/htdocs/phptutorial/" on the ubuntu vm server which is also the code server. Inside this folder is a file named "declarativeStatements.php" with contents.
Then from the index.php, i call this file using include.
index.php
<?php
echo '<a href="include.php"></a><br />';
Then the include.php has this content.
<?php
include __DIR__ . '/declativeStatements.php';
echo __DIR__ . '/declativeStatements.php';
The file permissions ont he phptutorial directory is
vagrant@DevServer:/opt/lampp/htdocs/phptutorial$ ls -la
total 44
drwxrwsrwx 2 vagrant vagrant 4096 Oct 22 00:01 .
drwxr-xr-x 6 root root 4096 Oct 4 09:07 ..
-rw-rw-rwx 1 vagrant vagrant 225 Oct 28 00:33 declarativeStatements.php
-rw-rw-rwx 1 vagrant vagrant 374 Oct 5 12:25 floatingpoints.php
-rw-rw-rwx 1 vagrant vagrant 375 Oct 28 00:34 include.php
-rwxrwxrwx 1 vagrant vagrant 459 Oct 22 00:07 index.php
-rw-rw-rwx 1 vagrant vagrant 30 Oct 5 00:25 integer.php
-rw-rw-rwx 1 vagrant vagrant 243 Oct 6 00:27 null.php
-rw-rw-rwx 1 vagrant vagrant 45 Oct 11 12:06 operators1.php
-rw-rw-rwx 1 vagrant vagrant 422 Oct 5 12:48 string.php
-rw-rw-rwx 1 vagrant vagrant 305 Oct 19 00:24 switch.php
but the output shows this when the include.php is called.
Warning: include(/opt/lampp/htdocs/phptutorial/declativeStatements.php): Failed to open stream: No such file or directory in /opt/lampp/htdocs/phptutorial/include.php on line 6
Warning: include(): Failed opening '/opt/lampp/htdocs/phptutorial/declativeStatements.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/phptutorial/include.php on line 6
/opt/lampp/htdocs/phptutorial/declativeStatements.php
The webserver is run via
/opt/lampp/lampp start
Any ideas?
I am having problem with testing example codes from the videos i am watching in youtube (sorry, just a hobby here for fun).
All of my php tutorial files are located on
"/opt/lampp/htdocs/phptutorial/" on the ubuntu vm server which is also the code server. Inside this folder is a file named "declarativeStatements.php" with contents.
Code:
<?php
// declarative
declare(strict_types=1); // This declaration is only significant to the the current page.
function sum(int $x, int $y) {
return $x + $y;
}
echo sum(5, 10);
echo sum(5, '10'); // This will not work
Then from the index.php, i call this file using include.
index.php
<?php
echo '<a href="include.php"></a><br />';
Then the include.php has this content.
<?php
include __DIR__ . '/declativeStatements.php';
echo __DIR__ . '/declativeStatements.php';
The file permissions ont he phptutorial directory is
vagrant@DevServer:/opt/lampp/htdocs/phptutorial$ ls -la
total 44
drwxrwsrwx 2 vagrant vagrant 4096 Oct 22 00:01 .
drwxr-xr-x 6 root root 4096 Oct 4 09:07 ..
-rw-rw-rwx 1 vagrant vagrant 225 Oct 28 00:33 declarativeStatements.php
-rw-rw-rwx 1 vagrant vagrant 374 Oct 5 12:25 floatingpoints.php
-rw-rw-rwx 1 vagrant vagrant 375 Oct 28 00:34 include.php
-rwxrwxrwx 1 vagrant vagrant 459 Oct 22 00:07 index.php
-rw-rw-rwx 1 vagrant vagrant 30 Oct 5 00:25 integer.php
-rw-rw-rwx 1 vagrant vagrant 243 Oct 6 00:27 null.php
-rw-rw-rwx 1 vagrant vagrant 45 Oct 11 12:06 operators1.php
-rw-rw-rwx 1 vagrant vagrant 422 Oct 5 12:48 string.php
-rw-rw-rwx 1 vagrant vagrant 305 Oct 19 00:24 switch.php
but the output shows this when the include.php is called.
Warning: include(/opt/lampp/htdocs/phptutorial/declativeStatements.php): Failed to open stream: No such file or directory in /opt/lampp/htdocs/phptutorial/include.php on line 6
Warning: include(): Failed opening '/opt/lampp/htdocs/phptutorial/declativeStatements.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/phptutorial/include.php on line 6
/opt/lampp/htdocs/phptutorial/declativeStatements.php
The webserver is run via
/opt/lampp/lampp start
Any ideas?