-2

I don't know why when i add a require_once function in my code, it can not run, always show that failed to open stream.

<?php  require_once("../../../../cadpro_vs2/include/admin/ad_nav.php") ?>

Any mistake on syntax or something, please help!

Can anyone help me?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Hoàng Trung Hiếu
  • 209
  • 1
  • 3
  • 14

2 Answers2

0

Maybe you are in the wrong work directory. Its a bad idea to rely on it (except you explictly want to access it) anyway. Use

require __DIR__ . '/../fruit.php';

or with pre-5.3

require dirname(__FILE__) . '/../fruit.php';

Remind, that paths starting with .., or . are not resolved against the include-path, but only against the current work directory.

To get more elaborated idea, visit require_once

Source: Require_once PHP Error

Community
  • 1
  • 1
Suyog
  • 2,472
  • 1
  • 14
  • 27
0

try this code

define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/cadpro_vs2/include/admin/ad_nav.php');

if this code cant help you, check your path. maybe file not exist

Salar Pourfallah
  • 1,402
  • 1
  • 9
  • 10