Forum Moderators: coopster
I am willing to divulge certain details of this kluge, but since I never go out in public naked alone, will wait to see if anyone else first posts a gem of a nasty kluge.
No really lengthy code dumps please; descriptions can be ugly enough.
I was just so happy to see ANYTHING render. To clean
things up, I removed all those silly things at the top
that made no sense to me, you know, Doctype, charsets,
all that silly stuff.
You can imagine the fun I had validating those pages
later.
- Larry
The most notable rediculousness was sentences with "quotes" in them from a database, and echo-ing them into onmouse events, that would then load dynamic urls. A total mess. The quotes wreak total havoc and I still cant get them to work 100%. I've try htmlentities, special chars and other nonesense.
I wish php could be set up to take other symbols as string markers. Ones that never appear in "real" language.
Ok, here's mine. I've got this php config file that I want to change every once in a while, and each time it's changed it'll only change one entry. I could have used the PEAR packgage Config, but thought, why bother learning how to use this new class, with all the extra bloat? I also didn't want to bother writing something to put the config file together - so I just made a function to find the place where a given variable or element in an array is set; the script reads in the file, locates that line, replaces it with the new config value, writes the it all to the file. Real smart, right?
Then I realized that some of the variables I was needing to change were elements of an array, of which there were more than one array using these element names. So I add comments to the config sheet to help 'localize' the arrays, and write another function to find the parts of the code that's inside these functions;
So now what this code does is read in the file, find the array needed as $arraysnippet, find the line in $arraysnippet that needs to be changed, and replace this in a copy of $arraysnippet called $newsnippet; It then replaces $arraysnippet with $newsnippet, and then writes the file.
If I'd just used the pear class, it would have simply been a matter of listing which variables I had in this sheet, modifying the ones I wanted modified, and sending these to the class; the config sheet would just be made again from scratch, all done by the class. As it turns out, I'll have to write something to produce the config sheet from scratch anyways since if an error ever creeps into the config sheet, as it's now written, the error will be reproduced in the modified config sheet.
Salsa: Neither leisure foreigner seized the weird heights. Remember this sentence and you'll have most of the exceptions.