Re: [PHP] turn off the www
Wouldn't $newUrl = 'https://' . substr( $_SERVER['SERVER_NAME'], 4 ) be a _hell_ of a lot faster? If one considers micro-seconds 'a _hell_ of a lot faster', then _maybe_ And it could be slower if you avoid sending someone from http://example.com/ to https://ple.com/ by adding a substring check. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Breaking up data efficiently
In my opinion you should save exceptions for, well, EXCEPTIONal problems. Either that or you use exceptions for a large system that discriminates against specific types of errors and handles each error type in a totally different way. Can we say bloat? Depending on the system, malformatted data may very well be exceptional. (adj. 1. being an exception; uncommon) Judging by the lack of error-checking in the OP, it seems to be the case. Using trigger_error or return false would both be reasonable solutions as well. Really, how errors are handled is up to the individual. My point was that Wee Keat may consider adding a few lines for validation. Certainly adding any error-checking will reduce efficiency, which is what the original question was regarding. (As an aside, some day i will have to find out how many times the word bloat appears on this list.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $mydata-StampDate
On 27/06/05, Jasper Bryant-Greene [EMAIL PROTECTED] wrote: John Taylor-Johnston wrote: I could just change the field type. But how do you calculate it? I don't see much to inspire a start. I'm not a full-time coder either. More of a tinkerer. I don't want someone to do it for me, but need to get my head around how to do it. http://ca3.php.net/manual/en/function.strtotime.php As I said, though, you should be using a MySQL date field. Have a look at the MySQL manual for the corresponding functions to the above -- there's probably a quicker way with MySQL too. Dates should almost always be stored as dates in a database, not varchars. This allows for more and/or faster date functions, sorting that works (it only works with -mm-dd format in varchars), and you can select the data into a unix timestamp instead of needing to strtotime() first. The calculation in mysql couldn't be much simpler. select datediff(StampDate, '2003-08-23') as StampDateDiff From the manual: DATEDIFF() returns the number of days between the start date expr and the end date expr2. expr and expr2 are date or date-and-time expressions. Only the date parts of the values are used in the calculation. mysql SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30'); - 1 http://mysql.org/doc/mysql/en/date-and-time-functions.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] removing chars from string
Paul Nowosielski [EMAIL PROTECTED] wrote: If a have a string thats 11 characters long how can I strip off the last two characters? Jay Blanchard [EMAIL PROTECTED] wrote: $newString = substr($oldString, 0, 8); echo $newString; substr's third argument is length, not position. It also accepts negative values which makes it go from the end, allowing you to do absolute lengths or relative. To make a string no more than 9 characters: substr($string, 0, 9); To always remove the last two characters of a string: substr($string, 0, -2); http://php.net/substr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Breaking up data efficiently
I agree, your implementation is efficient. It does depend on the data being entirely proper, however. If you can not be entirely sure (and you should rarely be), i might add a suggestion that increases code length, but decreases the chance of problems: You might consider creating a function to validate the location as well as list() = explode() it. $locations = explode('|', $booking-booking_flight_details); foreach ($locations as $location) $list[] = split_location($location); Create the function split_location to return the associative array or, if it is invalid, throws an exception. If PHP4, replace the exception with similar error handling. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ad management
On 27/06/05, Sebastian [EMAIL PROTECTED] wrote: i am looking for a simple ad management app to keep track of ad views/impressions. i was looking at phpadsnews, but it seems way too much bloat of what i need i to do. I am not aware of any such package, however you may way to keep in mind that what you need right now is not necessarily what you will need in the future. The bloat you see in some, such as phpadsnews, has likely been added because needs expanded. Your needs may also expand. Your client/manager may want to track impressions in a certain way in the future; will LightweightAdManager handle that? Most such packages start out fulfilling a simple need, and features are added as clients or managers desire new functionality. I agree that a lot of packages are bloated, but in many cases the bloat is there to provide flexibility so you do not need to rework everything to add feature Foo. If you are fully certain you will not need anything but a basic set of functions, then ignore this message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about HTTP 301 permanent redirects
On 27/06/05, Dr. Brad Lustick [EMAIL PROTECTED] wrote: I'm a novice trying to understand the exact construction of code for doing an HTTP 301 permanent redirect for a server coded in PHP. Could someone please tell me how I would handle the following example? http://www.nimblepedic.com/services-bodytools.php?i=bodytools WANT TO DO A HTTP 301 REDIRECT TO: http://www.nimblepedic.com/services.php/body_tools There are a few examples at http://php.net/header In your case you might want to do something like: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); header('Location: ' . $url); (Also, that's a hell of a signature.) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A Bug in string 'brbr eD'?
Are you viewing this via a web server? It's probably returning content-type text/html, which means that you might need to htmlspecialchars() that string. That's what i was thinking. It looks like how some browsers would render that string. Could you copy the relevant code into a message? Seeing pseudo-script is different from seeing what you are actually doing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: A Bug in string 'brbr eD'?
On 26/06/05, Jasper Bryant-Greene [EMAIL PROTECTED] wrote: Kevin L'Huillier wrote: Could you copy the relevant code into a message? Sure, either set the content-type to text/plain (to see the raw string rather than have the browser interpret it as HTML), like this: Sorry, Jasper. I meant the original poster of this thread. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with arrays
On 24/06/05, Josh Olson [EMAIL PROTECTED] wrote: for ($i = 0; $i count($array1); i++) $array1[$i][] = $array2[$i]; from kevin l'huillier That's basically what Mike wrote (only with array_push instead of []), and Bob improved upon. And they didn't mix the arrays up. I was only making the point that the solution was simple with a quick comment in IRC. I had not intended for it to be posted to the list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't even make a simple test RSS feed
On 6/24/05, Brian Dunning [EMAIL PROTECTED] wrote: What am I doing wrong? This doesn't work. The browser does not even load the page, no error or anything: The script looks fine and executed as expected on my machine. Try executing it from the command-line. Often if nothing loads in the browser, it is an error causing PHP to not send anything to the web server, even its normal errors. If you are using IIS it might also be the ISAPI module which has been notorious for stability. Restarting the Web Publishing Service sometimes helps. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Strange notation to create object
On 24/06/05, Jason Barnett [EMAIL PROTECTED] wrote: OK I'm pretty clear on it, but now I wonder: is variable assignment (=) the only place where the Zend Engine will copy a reference instead of reference the reference? In PHP 4, function arguments work the same way. Unless you use the reference operator you will be working on a copy of the object. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php