E
E
Evgeny Ivanov2018-02-08 07:54:40
PHP
Evgeny Ivanov, 2018-02-08 07:54:40

How to write the path to the file?

Something I'm confused.
Previously, everywhere I wrote relative paths like this

include_once ('file.php');
include_once ('folder/file.php');

And everything worked everywhere. Up crone. Crone says that there are no files in these paths.
And for him I wrote the path already like this. That given __DIR__ is an absolute path. And here I again need to include a couple of files in other files. And some of them will use crone. And part is not. How to write the path to the file?
include_once (__DIR__.'file.php');

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Ainur Valiev, 2018-02-08
@vaajnur

relative paths should not be used.
There are 2 ways to specify the path to the php file
1. respectively, here the cron must access via http:// so that the apache server (nginx) creates this variable. 2.
dirname(__FILE__)

A
Alexander Aksentiev, 2018-02-08
@Sanasol

https://getcomposer.org/doc/04-schema.md#files

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question