Jump to content

How to including without problem


Mhari

Recommended Posts

Hello,

how to include file without problem in path of files? And not causing error?

Example, if i am installing wordpress, i can install it in everywhere like home/a/b/c..

 

Please help me..

Link to comment
Share on other sites

You can either use a relative path instead of an absolute path, or have a global include file which defines things like the absolute path to the root of your application that you can use to include other files from that point.

Link to comment
Share on other sites

Most applications, like Wordpress, have a single include file that all other files include. It contains global application settings or options, like database connection information, the main URL of the site, things like that. It can also contain the path where your application is installed, so you can use that to include any other file. You can get the full path to the current directory using the __DIR__ constant, it will be set to the directory where the PHP file is.

 

<?php

echo 'This script is at ' . __FILE__ . '<br>';
echo 'The directory is ' . __DIR__ . '<br>';
echo 'The parent directory is ' . dirname(__DIR__) . '<br>';
http://php.net/manual/en/language.constants.predefined.php
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...