php-general Digest 22 Nov 2010 19:00:57 -0000 Issue 7049
php-general Digest 22 Nov 2010 19:00:57 - Issue 7049 Topics (messages 309606 through 309611): Re: My project requires creating office documents on PHP. Any recommendations on what to use? 309606 by: Aman Singh Re: Problem with functions and arrays... 309607 by: Richard Quadling Re: MySQL Query Help 309608 by: Simcha Younger Mysql data encryption / Transparent data encyrption 309609 by: nitesh nandy Re: Wordpress Page: How to add pagination? 309610 by: Rico Secada 309611 by: Bastien Koert Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Not sure of all office documents, but for Excel, you may want to try out http://phpexcel.codeplex.com/?ocid=soc-c-in-loc--cfphttp://www.google.com/url?q=http%3A%2F%2Fphpexcel.codeplex.com%2F%3Focid%3Dsoc-c-in-loc--cfpsa=Dsntz=1usg=AFrqEzdAuwZxP4NwbHVSOl8dkY6mlt2YoQ. From the page: Project providing a set of classes for the PHP programming language, which allow you to write to and read from different file formats, like Excel 2007, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP. On Sat, Nov 20, 2010 at 11:40 AM, chetan ahuja chetanahuj...@gmail.comwrote: My project requires creating office documents on PHP. Any recommendations on what to use? ---End Message--- ---BeginMessage--- On 20 November 2010 23:31, Jason Pruim li...@pruimphotography.com wrote: Hey Everyone! So I came across a problem that I don't know how to fix... I have searched and thought and just not having anything click as to where I am messing up... I have a few functions as follows: ?PHP function ddbYear($name, $message, $_POST, $option){ //Make sure to post form start/stop OUTSIDE of this function... //It's not meant to be a one size fits all function! echo NAME: . $name . BR; echo MESSAGE: . $message . BR; echo POST: . $_POST . BR; echo OPTION: . $option . BR; $sticky = ''; if(isset($_POST['submit'])) { $sticky = $_POST[{$name}]; echo STICKY: . $sticky; } //echo OPTION: ; //print_r($option); echo HTML select name={$name} option value=0{$message}/option HTML; foreach ($option as $key = $value){ if($key == $sticky) { echo 'option value=' . $key .' selected' . $value . '/option'; }else{ echo 'option value=' . $key .'' . $value . '/option'; } } echo HTML /select HTML; unset($value); return; } ? One for Month, Day Year... All the same exact code... When I get brave I'll combine it into 1 functions :) Now... What it's trying to do.. It's on a update form on my website. Basically pulls the info from the database and displays it in the form again so it can be edited and resubmitted... As I'm sure you can tell from the function it checks to see if the a value has been selected in the drop down box and if it has then set the drop down box to that value. I call the function like this: ?PHP $startYear = date(Y, $row['startdate']); //Actual DBValue: 1265000400 $optionYear = array(2010 = 2010, 2011 = 2011, 2012 = 2012, 2013 = 2013, 2014 = 2014); ddbYear(startYear, Select Year, $startYear, $optionYear); ? The output I'm getting is: THESE ARE THE ACTUAL UNPROCESSED (OTHER THEN SEPARATING) VALUES FROM THE DATABASE startmonth: 2 startday: 1 startYear: 2010 endmonth: 11 endDay: 30 endYear: 1999 THESE ARE THE VALUES INSIDE THE FUNCTION NAME: startYear MESSAGE: Select Year POST: 2010 OPTION: Array STICKY: 2 Now... The problem is that $sticky get set to 2 instead of 2010... But I can't figure out why... Anyone have any ideas? And just incase I didn't provide enough info here's a link that shows it happening: HTTP://jason.pruimphotography.com/dev/cms2/events/update_form.php?id=62 Thanks for looking and for your answers in advance! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It is extremely counter-intuitive to have parameters named after superglobal variables. ?php /** * This function looks like it does nothing. */ function EmptyFunction($_POST) { } // Build $_GET $_GET['Name'] = 'Richard'; print_r($_GET); print_r($_POST); EmptyFunction($_GET); print_r($_GET); print_r($_POST); ? Rather than doing nothing, any parameter passed to it will be assigned to the super global $_POST array. There is no pass be reference $_POST which would be one way to alter a variable that exists outside of the scope of the function. If your intention _IS_ to assign to the $_POST super-global, then just assign it. Don't pass it. Using any super global as a parameter is almost always NOT going to have the intent required. Things get really
Re: [PHP] Wordpress Page: How to add pagination?
perhaps you could just google wordpress pagination http://www.google.ca/#sclient=psyhl=enq=wordpress+paginationaq=1aqi=g4g-o1aql=oq=gs_rfai=pbx=1fp=88df74f51cdeec4c -- Bastien Cat, the other other white meat Here, this may help: http://lmgt4u.com/?q=wordpress+pagination Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't find existing file
On Mon, Nov 22, 2010 at 14:36, Dee Ayy dee@gmail.com wrote: Thes two lines means that they exist by using quoted and unquoted commands: ls ./photos/HPR-130-260_HD-3070-1.jpg ./photos/HPR-130-260_HD-3070-1.jpg ls ./photos/HPR-130-260_HD-3070-1.jpg ./photos/HPR-130-260_HD-3070-1.jpg Please use Reply-All to reply back to the list. Also, please note: ./photos/HPR-130-260_HD-3070-1.jpg != ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with functions and arrays...
On Nov 21, 2010, at 4:57 PM, Tamara Temple wrote: On Nov 20, 2010, at 5:31 PM, Jason Pruim wrote: ?PHP function ddbYear($name, $message, $_POST, $option){ Maybe it's just me, but using the name of a global as a function parameter just seems like a bad idea. Yes, you can do it. Should you? I think not. Especially, as, you are passing it a scalar below and treating it here like the global array. It was there as a hold over from when I originally made the functions which just had to deal with getting variables from the $_POST global. //Make sure to post form start/stop OUTSIDE of this function... //It's not meant to be a one size fits all function! echo NAME: . $name . BR; echo MESSAGE: . $message . BR; echo POST: . $_POST . BR; echo OPTION: . $option . BR; $sticky = ''; if(isset($_POST['submit'])) { Check the error messages -- since you're passing in $startYear as a scalar below, you shouldn't be able to access $_POST as an associative array. ini_set(display_errors, 1); error_reporting(-1); were both on and were not complaining about anything... $sticky = $_POST[{$name}]; echo STICKY: . $sticky; } //echo OPTION: ; //print_r($option); echo HTML select name={$name} option value=0{$message}/option HTML; foreach ($option as $key = $value){ if($key == $sticky) { echo 'option value=' . $key .' selected' . $value . '/option'; }else{ echo 'option value=' . $key .'' . $value . '/option'; } } echo HTML /select HTML; unset($value); return; } ? One for Month, Day Year... All the same exact code... When I get brave I'll combine it into 1 functions :) Now... What it's trying to do.. It's on a update form on my website. Basically pulls the info from the database and displays it in the form again so it can be edited and resubmitted... As I'm sure you can tell from the function it checks to see if the a value has been selected in the drop down box and if it has then set the drop down box to that value. I call the function like this: ?PHP $startYear = date(Y, $row['startdate']); //Actual DBValue: 1265000400 You're setting $startYear as a scalar value here. $optionYear = array(2010 = 2010, 2011 = 2011, 2012 = 2012, 2013 = 2013, 2014 = 2014); ddbYear(startYear, Select Year, $startYear, $optionYear); And passing it in to the $_POST variable in your function. Then you treat the $_POST variable as an associative array (seemingly much like the global $_POST array). ? The output I'm getting is: THESE ARE THE ACTUAL UNPROCESSED (OTHER THEN SEPARATING) VALUES FROM THE DATABASE startmonth: 2 startday: 1 startYear: 2010 endmonth: 11 endDay: 30 endYear: 1999 THESE ARE THE VALUES INSIDE THE FUNCTION NAME: startYear MESSAGE: Select Year POST: 2010 OPTION: Array STICKY: 2 Now... The problem is that $sticky get set to 2 instead of 2010... But I can't figure out why... Anyone have any ideas? And just incase I didn't provide enough info here's a link that shows it happening: HTTP://jason.pruimphotography.com/dev/cms2/events/update_form.php?id=62 Again, I will reiterate that taking the name of a global variable and using it as a parameter in a function is a bad idea. It can be done, and my in some cases have some uses, but I don't think the way you're using it is a good idea, and looks wrong to me as well. Turns out it was a conflict with the $_POST global.. Or my misunderstanding inside the functions... I changed that to another name and now it works fine... Thanks Tamara! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Procedural Autoloader?
Hey Everyone! Fresh off my problem with functions and arrays I come across something that I can't seem to find currently... The autoloader function that is in PHP 5+ works on classes... But I'm not finding anything that would do the same thing on the procedural end... Such as I have a folder typically called includes in my projects where I place all my function files... I would LOVE to use the autoloader to be able to just load them on demand... But in my quick searching/thinking I haven't found away too... So I thought I would see if anyone had invented that wheel yet before I go and try and do it my self :) I may also have a misunderstanding of how it is supposed to work since I don't truly understand OOP I've always done procedural... Any help on this one would be greatly appreciated it! :) Jason Pruim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Eclipse Manual
Dear list - Does anyone have a URL for the manual for Eclipse/PHP. Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 12:37 PM, Jason Pruim li...@pruimphotography.comwrote: The autoloader function that is in PHP 5+ works on classes... But I'm not finding anything that would do the same thing on the procedural end. I'll start by explaining how it typically works with classes. The Zend Framework is a popular web/application class library. It organizes its classes into packages much like Java, Python, and other languages, where each package is a folder that contains other packages and classes. In Java, packages are a language feature so you have java.util.List which is the fully-qualified name of the List class that lives in the java.util package. PHP doesn't have the notion of packages, though 5.3 introduced namespaces which are similar but different. The autoloader function in PHP takes a class name and locates the file that should define it. In Zend this is done by separating the folder names by underscores, e.g. Zend_Http_Request. The autoloader splits the class name on underscores and looks in registered folders for a folder named Zend, and inside that for another folder named Http, and inside that for a file named Request.php. Zend's autoloader class provides more features such as aliases for folders so ZF would map to Zend. The above is based on the convention of having one class per file. I doubt you'll be doing that for functions, so even if PHP had an autoloading mechanism for functions, you'd still need a way to map from function name to file name. I suppose you could do the same as above but drop the final name element when looking for the file. For example, the function math_trig_cos() would map to the function cos() defined in math/trig.php. But it's all academic because PHP does not support such a feature. You could probably create a PHP extension if you wanna roll up your sleeves and get dirty in C. :) David
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 15:37, Jason Pruim li...@pruimphotography.com wrote: Hey Everyone! Fresh off my problem with functions and arrays I come across something that I can't seem to find currently... The autoloader function that is in PHP 5+ works on classes... But I'm not finding anything that would do the same thing on the procedural end... Such as I have a folder typically called includes in my projects where I place all my function files... I would LOVE to use the autoloader to be able to just load them on demand... But in my quick searching/thinking I haven't found away too... So I thought I would see if anyone had invented that wheel yet before I go and try and do it my self :) I may also have a misunderstanding of how it is supposed to work since I don't truly understand OOP I've always done procedural... Any help on this one would be greatly appreciated it! :) There's no such thing, Prune. Autoloaders are for classes, and the only way you could have it work for functions would be to catch the error in the core and handle it at a lower level than your scripts (modified core or extension), because the error generated for an undefined function isn't a catchable fatal. Alternatively, you *could* write a function wrapper that utilizes function_exists() and the like, then rewrite all of your code to use that wrapper but how much sense does that make? ;-P -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 15:37, Jason Pruim li...@pruimphotography.com wrote: Hey Everyone! Fresh off my problem with functions and arrays I come across something that I can't seem to find currently... The autoloader function that is in PHP 5+ works on classes... But I'm not finding anything that would do the same thing on the procedural end... Such as I have a folder typically called includes in my projects where I place all my function files... I would LOVE to use the autoloader to be able to just load them on demand... But in my quick searching/thinking I haven't found away too... So I thought I would see if anyone had invented that wheel yet before I go and try and do it my self :) I may also have a misunderstanding of how it is supposed to work since I don't truly understand OOP I've always done procedural... Any help on this one would be greatly appreciated it! :) There's no such thing, Prune. Autoloaders are for classes, and the only way you could have it work for functions would be to catch the error in the core and handle it at a lower level than your scripts (modified core or extension), because the error generated for an undefined function isn't a catchable fatal. Alternatively, you *could* write a function wrapper that utilizes function_exists() and the like, then rewrite all of your code to use that wrapper but how much sense does that make? ;-P -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 2:24 PM, Daniel P. Brown daniel.br...@parasane.netwrote: On Mon, Nov 22, 2010 at 15:37, Jason Pruim li...@pruimphotography.com wrote: Hey Everyone! Fresh off my problem with functions and arrays I come across something that I can't seem to find currently... The autoloader function that is in PHP 5+ works on classes... But I'm not finding anything that would do the same thing on the procedural end... Such as I have a folder typically called includes in my projects where I place all my function files... I would LOVE to use the autoloader to be able to just load them on demand... But in my quick searching/thinking I haven't found away too... So I thought I would see if anyone had invented that wheel yet before I go and try and do it my self :) I may also have a misunderstanding of how it is supposed to work since I don't truly understand OOP I've always done procedural... Any help on this one would be greatly appreciated it! :) There's no such thing, Prune. Autoloaders are for classes, and the only way you could have it work for functions would be to catch the error in the core and handle it at a lower level than your scripts (modified core or extension), because the error generated for an undefined function isn't a catchable fatal. Alternatively, you *could* write a function wrapper that utilizes function_exists() and the like, then rewrite all of your code to use that wrapper but how much sense does that make? ;-P Shrug, if you want to really be dirty about it, you could just put a 'class' atop each file of functions. ?php class IWishTheseFunctionsWereOOInstead {} // :P function firstProceeduralFunc() { // .. } ? -nathan
Re: [PHP] Eclipse Manual
Ethan Rosenberg wrote: Dear list - Does anyone have a URL for the manual for Eclipse/PHP. Depends which one you are looking for PHPEclipse is on their site http://www.phpeclipse.com/wiki/General/PHPEclipseFAQ is a good starting point. If you must use PDT, then http://wiki.eclipse.org/index.php/PDT -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk// Firebird - http://www.firebirdsql.org/index.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 16:31, Nathan Nobbe quickshif...@gmail.com wrote: Shrug, if you want to really be dirty about it, you could just put a 'class' atop each file of functions. ?php class IWishTheseFunctionsWereOOInstead {} // :P function firstProceeduralFunc() { // .. } ? That's not going to be economical or allow him to autoload, though, because the autoloader is called when the class is instantiated. Prune could instantiate it thusly: ?php $foo = new IWishTheseFunctionsWereOOInstead(); firstProceeduralFunc(); // [sic] ? but it would be just as simple to do: ?php require dirname(__FILE__).'/includes/function.php'; firstProceeduralFunc(); // [sic, again] ? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On 22 November 2010 22:40, Daniel P. Brown daniel.br...@parasane.net wrote: On Mon, Nov 22, 2010 at 16:31, Nathan Nobbe quickshif...@gmail.com wrote: Shrug, if you want to really be dirty about it, you could just put a 'class' atop each file of functions. ?php class IWishTheseFunctionsWereOOInstead {} // :P function firstProceeduralFunc() { // .. } ? That's not going to be economical or allow him to autoload, though, because the autoloader is called when the class is instantiated. Not to mention that it has nothing to do with a procedural autoloader. Autoloading takes place if you try to instantiate an object of a class that PHP doesn't know about (yet). There is no such thing for functions. Either refactor your code so you don't have this problem (The Way To Go [tm]) or make an extension. End of discussion. Regards Peter -- hype WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On Nov 22, 2010, at 4:24 PM, Daniel P. Brown wrote: On Mon, Nov 22, 2010 at 15:37, Jason Pruim li...@pruimphotography.com wrote: Hey Everyone! Fresh off my problem with functions and arrays I come across something that I can't seem to find currently... The autoloader function that is in PHP 5+ works on classes... But I'm not finding anything that would do the same thing on the procedural end... Such as I have a folder typically called includes in my projects where I place all my function files... I would LOVE to use the autoloader to be able to just load them on demand... But in my quick searching/thinking I haven't found away too... So I thought I would see if anyone had invented that wheel yet before I go and try and do it my self :) I may also have a misunderstanding of how it is supposed to work since I don't truly understand OOP I've always done procedural... Any help on this one would be greatly appreciated it! :) There's no such thing, Prune. Autoloaders are for classes, and the only way you could have it work for functions would be to catch the error in the core and handle it at a lower level than your scripts (modified core or extension), because the error generated for an undefined function isn't a catchable fatal. Alternatively, you *could* write a function wrapper that utilizes function_exists() and the like, then rewrite all of your code to use that wrapper but how much sense does that make? ;-P How much sense do I ever make? :P Maybe it's time to get a book on OOP and start learning the concept.. Or find a better way to load my functions so I don't have to have 1 huge functions file or tons of includes if I have them all separate... Or maybe I can just bastardize classes enough to make something work :P I think most of my functions border on classes anyway... Off to google to see if I'm right! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't find existing file
Hi Daniel, Tell me if this isn't self explanatory: cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG ./photossized/001196-220197-0.jpg cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such file or directory Thanks for trying. Usually coders can read the error line and some folks like to see what you have done to attack the problem, hence the original ls line. I could have omitted the original Help at the bottom. I didn't think it would confuse anyone by adding it. And maybe you haven't seen the ls command. Solving issue #1: The getimagesize command wants filenames unquoted and unescaped. Those quotes were an attempt to handle spaces in the filename, but ended up introducing the error. For issue #2, I think you meant really does exist; of course my code is to blame; the script is in the same dir as the photos and photossized dirs. Thats what ./aDir means -- but remember that only some are failing; cases are preserved; yes, unlikely; the disk has a lot of space; cp is on the path because some work; Obviously it's a PEBKAC issue, that's why I came to this php list, to get it pointed out; etc. Solving issue #2 exec (or rather the shell) wants spaces escaped. And yes, some files were there, but the lookup table had single spaces while the filename being compared had double spaces. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
The simplest solution would be to move those functions into static methods of classes. Place one class in each file to organize your functions and use an autoloader to load the classes. You don't need to instantiate the class to use the autoloader--just reference it statically: // library/Math.php class Math { const PI = 3.14159; public static function sin($radians) {...} } ... $x = $radius * Math::cos(Math::PI * 0.5); David
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 16:47, Peter Lind peter.e.l...@gmail.com wrote: Not to mention that it has nothing to do with a procedural autoloader. Autoloading takes place if you try to instantiate an object of a class that PHP doesn't know about (yet). There is no such thing for functions. Either refactor your code so you don't have this problem (The Way To Go [tm]) or make an extension. End of discussion. Yeah, but I'm not yet done talking about it, so I may revisit it again in a few years when everyone's forgotten all about this thread. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't find existing file
On Mon, Nov 22, 2010 at 16:54, Dee Ayy dee@gmail.com wrote: Hi Daniel, Tell me if this isn't self explanatory: cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG ./photossized/001196-220197-0.jpg cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such file or directory Thanks for trying. Usually coders can read the error line and some folks like to see what you have done to attack the problem, hence the original ls line. I could have omitted the original Help at the bottom. I didn't think it would confuse anyone by adding it. And maybe you haven't seen the ls command. I'm presuming you mean that I didn't see it in your email, and I'm willing to leave it at that. Solving issue #1: The getimagesize command wants filenames unquoted and unescaped. Those quotes were an attempt to handle spaces in the filename, but ended up introducing the error. That's correct. Functions like getimagesize() handle their own slashing, et cetera. For issue #2, I think you meant really does exist; of course my code is to blame; the script is in the same dir as the photos and photossized dirs. Thats what ./aDir means -- but remember that only some are failing; cases are preserved; yes, unlikely; the disk has a lot of space; cp is on the path because some work; Obviously it's a PEBKAC issue, that's why I came to this php list, to get it pointed out; etc. No, I didn't, actually. I meant really doesn't exist. If the file really did exist at that location, it wouldn't be a problem. That may not be THIS problem, but it is A problem. Solving issue #2 exec (or rather the shell) wants spaces escaped. And yes, some files were there, but the lookup table had single spaces while the filename being compared had double spaces. Exactly. Interacting with the shell using backticks, exec(), passthru(), et al, is passed verbatim to the command line configured with the server's user:group CLI environment. Generally, when passing arguments, you should escapeshellarg() the arguments. And because the files were misnamed, that means they didn't exist. You knew which files you wanted, and to you, it was simple but the computer didn't know it, and when it looked for the files you wanted, they didn't exist. -- /Daniel P. Brown Network Infrastructure Manager Documentation, Webmaster Teams http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On 22 November 2010 22:02, David Harkness davi...@highgearmedia.com wrote: The simplest solution would be to move those functions into static methods of classes. Place one class in each file to organize your functions and use an autoloader to load the classes. You don't need to instantiate the class to use the autoloader--just reference it statically: // library/Math.php class Math { const PI = 3.14159; public static function sin($radians) {...} } ... $x = $radius * Math::cos(Math::PI * 0.5); David Would it be overboard to use a namespace? Aren't namespaces handled by the autoloader? If not autoload(), how about spl_autoloading? -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] rewriteTextLinks.php - make URLs in plain text clickable
I'm posting this in the hopes that it will be of some use to someone. I've put together a little regex function for finding and transforming links in blocks of plain text into clickable links while applying some heuristics to handle the more common edge cases. Unlike so many solutions I've found online this one handles more edge cases including periods and commas at the end, surrounding parentheses, trailing periods on only the domain part, etc. etc. http://formvista.com/fv-b-12-170/rewriteTextLinks-a-function-to-make-links-in-blocks-of-text--quot-clickable-quot-.html --- Yermo LamersDTLink, LLC Software Developerhttp://www.dtlink.com http://miles-by-motorcycle.comFor Motorcycle Travellers http://formvista.comEntrepreneurs CMS and Business Platform --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Procedural Autoloader?
On Mon, Nov 22, 2010 at 3:05 PM, Richard Quadling rquadl...@gmail.comwrote: Would it be overboard to use a namespace? Aren't namespaces handled by the autoloader? If not autoload(), how about spl_autoloading? Autoloading is for determining the path and filename where a named item is defined. Namespaces only give you the path. Even with namespaces, you'd still need to require the files that contain the functions. Plus you'd also need to use the namespace everywhere you use the function because you cannot alias functions--only classes. :( David
Re: [PHP] rewriteTextLinks.php - make URLs in plain text clickable
Hello Yermo, thanks a lot! I will try this on my project (http://oire.org/) and I'll inform you if I modify it somehow. -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion - Original message - From: Yermo y...@dtlink.com To: php-general@lists.php.net php-general@lists.php.net Date: Tuesday, November 23, 2010, 1:04:19 AM Subject: [PHP] rewriteTextLinks.php - make URLs in plain text clickable I'm posting this in the hopes that it will be of some use to someone. I've put together a little regex function for finding and transforming links in blocks of plain text into clickable links while applying some heuristics to handle the more common edge cases. Unlike so many solutions I've found online this one handles more edge cases including periods and commas at the end, surrounding parentheses, trailing periods on only the domain part, etc. etc. http://formvista.com/fv-b-12-170/rewriteTextLinks-a-function-to-make-links-in-blocks-of-text--quot-clickable-quot-.html --- Yermo LamersDTLink, LLC Software Developerhttp://www.dtlink.com http://miles-by-motorcycle.comFor Motorcycle Travellers http://formvista.comEntrepreneurs CMS and Business Platform --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php