Ninjakreborn Posted October 23, 2006 Share Posted October 23, 2006 I have rewritten a huge skeleton for a framework. My own personal portable framework I am reusing in all my projects.Some of the first few functions I came up with I intended to deal with some issue's i was running across. I find myself fiddling with php.ini sometimes. So I wrote some functions to deal with these, I was wanting to get some advice on these, or ideas on increasing functionality of these functions. Or if someone thinks these are faulty what they would suggest.THe first takes a number. When the number is taken, it put's it into the case switch statement.when I first start up it defaults aterror(5);so I can see all errorsthen when I am done, I change it to error(0) which automatically set's it all back to the securest settings.The second function is what I use with databasing.I get tired of cutting off magic quote's, and I alway's like working with that off, so I can do it myself, I had issue's with it in the page, so with this, I end up having it do just that.When I passinisettings("safe");it turns off the magic quotes, and make's sure that register globals is off, it start's off at that valueif for some reason I needed the register global's on for a 3rd party(don't normally use them), then I can just pass inisettings("no");well tehcnically there's no point for the other so I will probably take that off later. But for now, this is the general idea[code]<?php// The following function set's the level of error display. function error($elevel) {switch ($elevel) { case 0: error_reporting(0); // off ini_set('display_errors', 'Off'); ini_set('log_errors', 'On'); case 1: error_reporting(E_ERROR | E_WARNING | E_PARSE); // simple running errors case 2: error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); // most errors case 3: error_reporting(E_ALL ^ E_NOTICE); // all except notice, php.ini default case 4: error_reporting(E_ALL); // all errors case 5: error_reporting(E_ALL | 'E_STRICT'); // all with strict }}// This can be set to safe or not, safe makes the safest php.ini settings// not, does not.function inisettings($inisettings) {switch ($inisettings) { case "safe": ini_set("magic_quotes_gpc", 0); ini_set("register_globals", 0); case "not": ini_set("register_globals", 1); }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24875-ideas-for-framework/ Share on other sites More sharing options...
redbullmarky Posted October 23, 2006 Share Posted October 23, 2006 i'm not sure of your question here, if there is one.however, i'd suggest that a function that turns register_globals on or off is a waste of time - mainly because you should always code without needing it on, and because it's gonna be disappearing with the next version of php anyway. same goes for magic quotes - the problem with having a function that turns it on or off is that you'll wind up coding different projects in different ways depending on whether you 'decide' to have it on or not. keeping coding consistency will help you expand the project in the future when you come back to it.i never personally touch the php.ini file after one initial setup. turning display_errors off, register_globals off, magic_quotes_runtime, etc, all off. the only thing i EVER need to change in terms of PHP settings is error_reporting/display_errors/display_startup_errors all go on, but i always do these in a htaccess file so that if i move my project to a different server (which is 99% the case when developing for a client on your machine before putting it on theirs) - that way, i dont need to remember what settings in my PHP.ini file i need to set on a clients server.also, using ini_set for errors doesnt really work for me. in the event, for example, i get a file that has a parse error - missing bracket, etc. as this means the file wont be parsed at all, neither will the ini_set line - meaning you're gonna be facing a blank page facing the mundane task of debugging your code.seriously, if you can't beat 'em, join 'em - i've mentioned it before, but i chose the [url=http://www.codeigniter.com]CodeIgniter[/url] framework to model my own framework on, because its very simple, mostly well written, and (with a few slight changes to the structure) very easy to build around, with a plugin architecture so that things only get included if they're required by certain scripts. also based on the MVC pattern (which i dont know what i was ever doing without it) and tidy URL's. i have a single copy of my framework on my server, and so far i have about 3 development sites that are using it already. and adding extra functionality just requires me digging into its code, making some changes, without worrying about breaking a thing. seriously, take a look at it - even if just for educational purposes. you'll pretty soon realise that incorporating your own custom error handling routines, debugging scripts, logging scripts, etc, is as easy as pie and far outweighs mucking around with settings all the time.cheersMark Quote Link to comment https://forums.phpfreaks.com/topic/24875-ideas-for-framework/#findComment-113383 Share on other sites More sharing options...
trq Posted October 23, 2006 Share Posted October 23, 2006 I dont really see much point in your error() function, its bassically just wrapping an already existing php function into something that IMO is less readable. Quote Link to comment https://forums.phpfreaks.com/topic/24875-ideas-for-framework/#findComment-113386 Share on other sites More sharing options...
Ninjakreborn Posted October 23, 2006 Author Share Posted October 23, 2006 Ok. thanks for the advice.I will keep these both in mind.Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/24875-ideas-for-framework/#findComment-113388 Share on other sites More sharing options...
Daniel0 Posted October 25, 2006 Share Posted October 25, 2006 Here is some corrections to your code:It is E_STRICT and not 'E_STRICT' as E_STRICT is a constant and not a string.When each case "ends" you will have to use [url=http://php.net/break]break[/url]. Quote Link to comment https://forums.phpfreaks.com/topic/24875-ideas-for-framework/#findComment-114187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.