How to check for two files

In my installs.php application in CodeIgniter, I would like to check if two files exist and install them accordingly.

Where, if the files exist, then they will be updated, otherwise go to step 1.

Is there a better and safer way?

$admin = dirname(FCPATH) . '/admin/config/database.php'; $catalog = dirname(FCPATH) . '/catalog/config/database.php'; if (file_exists($admin, $catalog)) { $route['default_controller'] = "upgrade/index"; $route['404_override'] = ''; } else { $route['default_controller'] = "step_1/index"; $route['404_override'] = ''; } 
+6
source share
1 answer

Try the following:

You need to check the existence of the file separately.

 if (file_exists($admin) && file_exists($catalog)) { $route['default_controller'] = "upgrade/index"; $route['404_override'] = ''; } else { $route['default_controller'] = "step_1/index"; $route['404_override'] = ''; } 

In the manual you can read file_exists .

+3
source

Source: https://habr.com/ru/post/983086/


All Articles