Author Topic: Advance PHP question  (Read 580 times)

Offline toxin

  • Level 21
  • *
  • Posts: 231
  • Reputation: +4/-2
    • View Profile
    • Encore Montreal
Advance PHP question
« on: January 21, 2009, 06:17:40 AM »
I was just wondering if you could alter the php.ini  on a sever to redirect to a list of your custom functions. Yes I could use the include but if I have 14 domains on one host it would be a lot easer if I could just keep the functions in the php folder and not have to place include in any of my pages just do like normal built in functions just declare the name and go.

It may take other coding knowledge like C.
« Last Edit: January 21, 2009, 06:54:26 AM by toxin »

Offline siefate

  • Level 2
  • *
  • Posts: 3
  • Reputation: +0/-0
    • View Profile
Re: Advance PHP question
« Reply #1 on: January 21, 2009, 11:20:16 AM »
I think auto_append_file will work. Just tested - it works.

http://us2.php.net/manual/en/ini.core.php

Quote
auto_append_file string

Specifies the name of a file that is automatically parsed after the main file. The file is included as if it was called with the require() function, so include_path is used.

The special value none disables auto-appending.

Note: If the script is terminated with exit(), auto-append will not occur.
 

Offline lolninja

  • Level 19
  • *
  • Posts: 194
  • Reputation: +5/-0
  • BSc powered Programmer
    • View Profile
    • HTTPmmo
Re: Advance PHP question
« Reply #2 on: January 21, 2009, 12:46:38 PM »
Hey, this is what I use, if its not what your looking for please disregard.

This has to be added to my index file, as I use an MVC with front controller for all my development it only occurs once per site...

Code: [Select]
addIncludePath(
array(
dirname(__FILE__).'/../../bah',
dirname(__FILE__).'/../../meh',
dirname(__FILE__).'/../../humpf'
)
);

/**
 * Used to add any needed paths to the systems include.
 * @param array $paths Contains a collection of paths which need adding to the include path.
 * @return void
 */
function addIncludePath($paths)
{
if (!is_array($paths))
return false;
foreach ($paths as $path)
if (!is_dir($path))
throw new Exception("The following include path could not be found '$path'.");
$inc = explode(PATH_SEPARATOR, ini_get('include_path'));
$inc = array_merge($inc, $paths);
$inc = implode(PATH_SEPARATOR, $inc);
ini_set('include_path', $inc);
}

Offline toxin

  • Level 21
  • *
  • Posts: 231
  • Reputation: +4/-2
    • View Profile
    • Encore Montreal
Re: Advance PHP question
« Reply #3 on: January 21, 2009, 09:55:22 PM »
Thank you. I searched but I guess I was not typing it the correct way.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal