PHP4 - $class_name::method_name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Justin Koivisto

    PHP4 - $class_name::method_name

    Time for me to ask a question for you all... This is what I want to do:

    $rslt=$class_na me::get_nodes($ branch,$db,$pg_ title);

    $class_name has the name of the class I want to call the method from.

    Here is the expected error:
    parse error, unexpected T_PAAMAYIM_NEKU DOTAYIM in file.php on line 52

    Now, is there a way I can accomplish this? Will I get stuck doing a
    switch($class_n ame) for it?

    Maybe a twist of the login a bit?

    Here's the full thing...

    Generating a list of the pages, sub-pages, sub-sub-pages, etc. dynamicly
    in a CMS...

    ---
    1 get an array of the pages at a certain node
    Array is like:
    Array (
    [$PATH/site-map/] => 9
    [$PATH/request/] => 6
    [$PATH/news/] => 1
    )

    Each integer represents a "page type." Each type has it's own class.
    Some of the classes create links to sub-pages that aren't defined in
    a nav menu somewhere else. (Like news releases where you may have a
    few links like: $PATH/news/?id=55

    2 check each node entry's page type and decide if it creates it's own
    sub-pages or not. There are database records for each page type that
    holds its id, class_name (used when the object is created), an
    "installed" Y/N field and a "recurse" Y/N flag.

    3 if "recurse" is set to 'Y', then call that page's class method called
    "get_nodes" - there are no objects of that type specified, so we just
    want to make a static call to the method.

    Then take this node and do a recursive call back to step 1.
    ---

    Can anyone think of a more elegant or "better" way to do this?

    --
    Justin Koivisto - spam@koivi.com

  • Janwillem Borleffs

    #2
    Re: PHP4 - $class_name::me thod_name

    Justin Koivisto wrote:[color=blue]
    > Time for me to ask a question for you all... This is what I want to
    > do:
    >
    > $rslt=$class_na me::get_nodes($ branch,$db,$pg_ title);
    >
    > $class_name has the name of the class I want to call the method from.
    >
    > Here is the expected error:
    > parse error, unexpected T_PAAMAYIM_NEKU DOTAYIM in file.php on line 52
    >
    > Now, is there a way I can accomplish this? Will I get stuck doing a
    > switch($class_n ame) for it?
    >[/color]

    See: http://nl.php.net/manual/en/function.call-user-func.php


    JW



    Comment

    • Justin Koivisto

      #3
      Re: PHP4 - $class_name::me thod_name

      Janwillem Borleffs wrote:
      [color=blue]
      > Justin Koivisto wrote:
      >[color=green]
      >>Time for me to ask a question for you all... This is what I want to
      >>do:
      >>
      >>$rslt=$class_ name::get_nodes ($branch,$db,$p g_title);
      >>
      >>$class_name has the name of the class I want to call the method from.
      >>
      >>Here is the expected error:
      >>parse error, unexpected T_PAAMAYIM_NEKU DOTAYIM in file.php on line 52
      >>
      >>Now, is there a way I can accomplish this? Will I get stuck doing a
      >>switch($class _name) for it?
      >>[/color]
      >
      > See: http://nl.php.net/manual/en/function.call-user-func.php[/color]

      forgot about that one... thanks!

      --
      Justin Koivisto - spam@koivi.com

      Comment

      • Qiang Xue

        #4
        Re: PHP4 - $class_name::me thod_name

        "Justin Koivisto" <spam@koivi.com > wrote in message news:_fqXc.1072 $j1.19953@news7 .onvoy.net...[color=blue]
        > Time for me to ask a question for you all... This is what I want to do:
        >
        > $rslt=$class_na me::get_nodes($ branch,$db,$pg_ title);
        >
        > $class_name has the name of the class I want to call the method from.
        >
        > Here is the expected error:
        > parse error, unexpected T_PAAMAYIM_NEKU DOTAYIM in file.php on line 52
        >
        > Now, is there a way I can accomplish this? Will I get stuck doing a
        > switch($class_n ame) for it?
        >[/color]

        Use eval() function.
        eval("\$rslt=$c lass_name::get_ nodes(\$branch, \$db,\$pg_title );");


        Comment

        Working...