Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php include_once not working

Tags:

include

php

What would be the reasons of a non working include_once?

Here's my folder hierarchy:

/Php/Controls/GridView/GridView.php
/Php/Controls/Form/Form.php

In "Form.php":

include_once '../GridView/GridView.php';

I'm getting this error:

Warning: include_once(../GridView/GridView.php) [function.include-once]: failed to open stream: No such file or directory in ...Form.php on line 4

Warning: include_once() [function.include]: Failed opening '../GridView/GridView.php' for inclusion (include_path='.;C:\php\pear') in ...Form.php on line 4

Please tell me if you want more information.

like image 918
Jean-Philippe Leclerc Avatar asked Apr 07 '11 23:04

Jean-Philippe Leclerc


3 Answers

In Form.php use

include_once dirname(__FILE__) . '/../GridView/GridView.php';

This creates an absolute path, but relative to the file, where its called from.

like image 168
KingCrunch Avatar answered Sep 19 '22 16:09

KingCrunch


It can't find the file.

You should use a full path, like /Php/Controls/GridView/GridView.php instead of a relative one.

like image 43
Tyler Carter Avatar answered Sep 18 '22 16:09

Tyler Carter


Try this:

include_once './php/Controls/GridView/GridView.php';
like image 35
Frantisek Avatar answered Sep 22 '22 16:09

Frantisek