Welcome guest, is this your first visit? Click the "Create Account" button now to join.

User Tag List

Results 1 to 3 of 3
  1. #1
    Intermediate
    Join Date
    Mar 2008
    Posts
    1,776
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Obliviate missing endpage()'s

    I have to admit it's been some time since I laid my hands on an MCCodes script, so best practices out the window.
    I would like to give MCCodes developers a useful tip.

    How many times haven't you missed a $h->endpage(); initialization? I know I have had my fair share of times.
    When it comes to output buffering for template systems, it's really a nuisance to work with.

    So, I've come up with a hack for it...
    MCCodes uses a class named headers for all it's templating needs, and using a bit of OOP knowledge one can automatically "close" a script that doesn't have the endpage() initialization present.

    It's called a destructor. It executes automatically every time the class is destroyed, or in human terms, when the script has finished executing.
    One can simply place the endpage() initialization in there, with a logical statement, so that you never get caught of guard by it again.

    So here's a little bit of code that could make your life easier... It works on all versions of MCCodes, to my knowledge that is.


    It might be useful to some, and not to others.
    But I just thought I would share this age old hack.

    Spudinski.
    Last edited by Spudinski; 02-20-2012 at 10:18 PM. Reason: I = Fool.

  2. #2
    Administrator
    Join Date
    May 2006
    Posts
    152
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Eh, I think you made a typo in the method name (__destruct?)... Otherwise, good stuff. The original code was not written with PHP 5 in mind, though, hence why something like this isn't already there.
    MCCodes Primary Developer
    http://mccodes.com/

    Twitter @Dabomstew

  3. #3
    Intermediate
    Join Date
    Mar 2008
    Posts
    1,776
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dabomstew View Post
    Eh, I think you made a typo in the method name (__destruct?)... Otherwise, good stuff. The original code was not written with PHP 5 in mind, though, hence why something like this isn't already there.
    Thanks for mentioning that silly mistake of mine.

    Even if it was written with PHP5 in mind, I get why something like this is not implemented.
    My best guess would be conforming to a specific coding style.

    But, please be aware that this is not to discredit MCCodes, it's the other way around actually.
    This is just a simple hack I mostly use on development environments, it's a short-cut method of doing things that isn't possible with the current MCCodes architecture.

 

 

Similar Threads

  1. possible Items shown in veiwuser(missing something?)
    By Mcfarlin in forum General Discussion
    Replies: 12
    Last Post: 11-21-2009, 10:54 AM
  2. [v2] itemuse.php missing code for jail/hospital/courses?
    By dlite in forum General Discussion
    Replies: 1
    Last Post: 04-10-2009, 07:21 PM
  3. added effects not working. any ides what i am missing here
    By hirev in forum General Discussion
    Replies: 1
    Last Post: 06-24-2008, 06:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •