Jump to content

stalkmadude

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by stalkmadude

  1. I've given a try by moving to __construct but no luck. Could you please explain with small demo?

     

    Edit: I think i got it working :) Could you explain me a method so that I don't need to keep writing new ClassName everytime?

  2. Hello,

     

    I'm having hard time with spl_autoload_register function specially when its inside a class. I would appreciate any help :)

     

    This is my index.php

    <?php
    require('./loadclasses.php');
    ?>
    

    loadclasses.php

    <?php
    class loadclasses
    {
        function autoLoader($className)
        {
            $fileName = str_replace("_", PATH_SEPARATOR, $className);
    
            include($fileName);
        }
    
        spl_autoload_register('autoLoader');
    }
    

    But i keep getting this error

    Parse error: syntax error, unexpected 'spl_autoload_register' (T_STRING), expecting function (T_FUNCTION) in d:\xampp\htdocs\welcomemanager\loadclasses.php on line 11

     

    I am running php 5.4 version on xmapp

     

    thanks again!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.