Parse a file that contains a function before

I have INI files in the form of:

  • root/languages/en/regform_registration.ini
  • root/languages/en/reports_report.ini
  • root/languages/en/profiles_update.ini

And other PHP files in the form of:

  • root/forms/registration.php
  • root/reports/report.php
  • root/profiles/update.php

In the previous as you can see the name of the INI files will always be foldername_phpfilename.ini

Now, for example, in the file registration.php at the moment I have this

$lang_values = parse_ini_file('root/languages/en/regform_registration.ini');

And what I am trying to do is have a function that runs everytime a file is requested like if someone calls the file registration.php a function will run and parse the values in the ini file to have them available when parsing the file

I think you are saying you want a more anonymous function which will do this:


$blah = "myfile";

$lang_values = parse_ini_file('root/languages/en/regform_'.$blah.'.ini');

// ... and so on 

If so var_dump( $_SERVER) and see where you can spot the filename and parse it out of one of the vars, or use FILE.

Also look at these functions;

Appypollyloggies if I have misunderstood your point…