Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> jak wywolac? klasa::metod(); gdzie 'klasa' jest wartoscia..
patrycjusz
post
Post #1





Grupa: Zarejestrowani
Postów: 263
Pomógł: 0
Dołączył: 13.07.2003
Skąd: wawa

Ostrzeżenie: (0%)
-----


Jak w temacie a dokładniej...[php:1:1ee277504a]<?php
function MOD($action)
{
include_once MODS.$action.'.php';
action::perform();
}

?>[/php:1:1ee277504a]
Zwraca blad że klasa action nie istnieje i tutaj wlasnie moje pytanie jak w tym przypadku zastosować jakiś "alias" własnie na tą nazwe klasy? bo w przypadku podstawienia zmiennej $action jest oczywiscie parse error a przypadku jak powyzej ze takowej klasy nie ma (IMG:http://forum.php.pl/style_emoticons/default/rolleyes.gif)
Z góry dziękuje za pomoc.
Pozdrawiam patS.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
DeyV
post
Post #2





Grupa: Zarząd
Postów: 2 277
Pomógł: 6
Dołączył: 27.12.2002
Skąd: Wołów/Wrocław




No to prosze - zauwaz, ze dla adodb przeznaczyłem sobną metodę. Być może dla smarty tez by było warto... (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Dodatkowo chciałem zauważyć, ze zawsze w CORE dołaczam 2 klasy c_error i c_info - które nie są oczywisćie konieczne do poprawnego działania. (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

[php:1:8d154cdda7]<?php
/**
* 03-12-07 by DeyV
*/
class core{

function core( $arrParm='' ) { $this->__construct( &$arrParm ); }

var $arrDir = array(
'class' => 'core/class/' ,
'mods' => 'core/mods/' ,

);

var $arrMods = array();
var $arrClass = array();

var $objError, $objInfo ;


function __construct( $arrParm ='' )
{
if( !empty( $arrParm['dirClass'] ) ) {
$this->arrDir['class'] = $arrParm['dirClass'] ;
}
if( !empty( $arrParm['dirMods'] ) ) {
$this->arrDir['mods'] = $arrParm['dirMods'] ;
}


require_once $this->arrDir['class'] . "c_error.php";
$this->objError = new c_error;

require_once $this->arrDir['class'] . "c_info.php";
$this->objInfo = new c_info;

}

function isSetMod( $strName='', $strPrefix='' )
{
return( isset($this->arrMods[ $strPrefix . $strName ] ) );
}


function &getMod( $strName='', $strPrefix='' )
{
if( empty( $strName ) )
{
return FALSE;
}

if( $this->isSetMod( $strName , $strPrefix ) )
{
return( $this->arrMods[ $strPrefix . $strName ] );

}elseif( class_exists( $strName ) )
{
$this->arrMods[ $strPrefix . $strName] = new $strName;
return( $this->arrMods[ $strPrefix . $strName] );

}elseif( file_exists ( $this->arrDir['mods'] . $strName . '.mod.php' ) )
{
include_once( $this->arrDir['mods'] . $strName . '.mod.php' );
if( class_exists( $strName ) )
{
$this->arrMods[$strPrefix . $strName] = new $strName;
return( $this->arrMods[ $strPrefix . $strName] );
} else
{
return FALSE;
}
}else
{
trigger_error('bład: nie mozna zaladowac moda <b>'. $strName . '</b> ('. $this->arrDir['mods'] . $strName . '.mod.php)' );
return FALSE;
}
}



function &getADoDB( )
{
if( empty( $this->arrClass['ADoDB'] ) )
{
require_once('../lib/adodb/adodb.inc.php');


$this->arrClass['ADoDB'] =& ADONewConnection( $GLOBALS['dbtyp'] );
$this->arrClass['ADoDB'] -> debug = $GLOBALS['dbdebug'];

if( false === $this->arrClass['ADoDB'] ->
Connect( $GLOBALS['dbhost'], $GLOBALS['dbuser'], $GLOBALS['dbhaslo'], $GLOBALS['dbname'] ) )
{
$this->objError->dodaj("Bł&plusmn;d startu","Brak połaczenia z baz&plusmn; danych");
return false;
}
}
return $this->arrClass['ADoDB'] ;
}
}

?>[/php:1:8d154cdda7]
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 6.10.2025 - 04:48