Re: [PHP] how to post a question?
Ryan A wrote: Hey Rich, The str_replace calls are kinda expensive IMHO, a good regex would be better I'd be interested to see a benchmark (any benchmark) where str_replace is SLOWER than the corresponding Regex... I am not very good with RegEx's myself, and I have never benchmarked any of them but I was told or read (when i first started learning php) that using multiple str_replace()s are not a good idea and to use a regex instead. (Thats why I wrote the "IMHO",if i was wrong one of the gurus here could correct me) It kind of makes sense, for example using this from the php site: $phrase = "You should eat fruits, vegetables, and fiber every day."; $healthy = array("fruits", "vegetables", "fiber"); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase); in the above, first it searches the entire phrase for the first parameter (fruits) then it starts again fro the second parameter (vegetables) etc, if you have a really long text it could be quite process intensivebecause it would have to go through the whole text searching for the parameters one by oneright? You're the guy who usually helps me (and a whole lot of others) when we have questions isn't he just! :-) I have to wonder how long his keyboards last ;-), or whether he retro-fits them with smoke alarms (speedtyping -> overheating -> fire) so I am really interested on your view on this, and why your view favours one side more than the other. regexps require a complete engine (in the same way as PHP is a engine) in order to be parsed. loading/initializing such an engine is heavier than doing a 'simple' search and replace action performance results (between str_replace() and pre_replace()) will definitely be skewed when comparing simple regexps against a comparable str_replace() because (to start with) the overhead of calling a function in php (which is why its better to call str_replace() with arrays in param 1 and 2 rather than calling str_replace() multiple times) ...also sporadic CPU load due to totally unrelated processes (even when running on your local machine) can totally skew a benchmark test. I think you can trust Richard on this one! and if you don't ... :-) ... then I bet you a beer he'd say "we'll then, why not test it and see!" Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hey Rich, > > The str_replace calls are kinda expensive IMHO, a good regex would be > > better > I'd be interested to see a benchmark (any benchmark) where str_replace is > SLOWER than the corresponding Regex... I am not very good with RegEx's myself, and I have never benchmarked any of them but I was told or read (when i first started learning php) that using multiple str_replace()s are not a good idea and to use a regex instead. (Thats why I wrote the "IMHO",if i was wrong one of the gurus here could correct me) It kind of makes sense, for example using this from the php site: $phrase = "You should eat fruits, vegetables, and fiber every day."; $healthy = array("fruits", "vegetables", "fiber"); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase); in the above, first it searches the entire phrase for the first parameter (fruits) then it starts again fro the second parameter (vegetables) etc, if you have a really long text it could be quite process intensivebecause it would have to go through the whole text searching for the parameters one by oneright? You're the guy who usually helps me (and a whole lot of others) when we have questions so I am really interested on your view on this, and why your view favours one side more than the other. Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
On Fri, July 22, 2005 10:11 am, Ryan A said: > The str_replace calls are kinda expensive IMHO, a good regex would be > better I'd be interested to see a benchmark (any benchmark) where str_replace is SLOWER than the corresponding Regex... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Chirantan Ghosh wrote: Hello Edward, I did try your approach in this page http://www.homecare1.biz/public_html/PHPsiteTest01.html with no avail. How would I find out if I have fopen wrappers enabled? This page is remote hosted ( Hosted by Godaddy.com who state I have PHP/MySQL enabled). CODE USED: === All you need to have in the page is this code: htmlentities(file_get_contents('http://www.dtcc.com/ThoughtLeadership/menu.htm')); ?> you don't need this either: Thanks for the help, Chirantan Since it's a remote server, it's quite lilely that they've disabled fopen wrappers. It can be a security concern for hosting providers. All you can do is ask them if they allow it, they should be able to tell you but I really doubt that they do. You can check what they have configured php for by running this in a page: That should give you a pretty page with a lot of information about what is available for you to run through php. Good luck! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hello Edward, I did try your approach in this page http://www.homecare1.biz/public_html/PHPsiteTest01.html with no avail. How would I find out if I have fopen wrappers enabled? This page is remote hosted ( Hosted by Godaddy.com who state I have PHP/MySQL enabled). CODE USED: === http://www.dtcc.com/ThoughtLeadership/menu.htm')); ?> Thanks for the help, Chirantan - Original Message - From: "Edward Vermillion" <[EMAIL PROTECTED]> To: "Chirantan Ghosh" <[EMAIL PROTECTED]> Cc: Sent: Friday, July 22, 2005 12:26 PM Subject: Re: [PHP] how to post a question? Chirantan Ghosh wrote: Hi Edward, I would simply like to print the remote Menu page( http://www.dtcc.com/ThoughtLeadership/menu.htm ) in a new page. I did the Error report print because I had no idea for what reason my PHP code was working. The menu is used as a header as well(the root file is JS which I can't use as I don't know all the directories of dtcc.com ) I am simply trying to impress a non technical person of the company so I can get a design contract. How can print the menu in different domain html pages? ( I would like to use PHP as server language) Thanks, Chirantan First try this: print htmlentities(file_get_contents('http://www.dtcc.com/ThoughtLeadership/menu.htm')); ?> That will let you see the HTML in your browser. If you don't get anything then either your request is being blocked by a firewall or you don't have fopen wrappers enabled. I'm betting on the latter though. Are you running a local install of php or through a remote server? You should be generating some kind of errors if your not getting anything back. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hey, Some more _dirty code_ as posted on http://php-php.com/a2ztips/test.php, http://www.dtcc.com/ThoughtLeadership/menu.htm'); $o=array("../dtcc.css","images/","/http","..http:"); $n=array("http://www.dtcc.com/dtcc.css","http://www.dtcc.com/ThoughtLeadersh ip/images/","http","http:"); $filename = str_replace($o, $n, $filename); $old = array("http://www.dtcc.com/ThoughtLeadership/images/dtcc_banner_logo.gif";, "http://www.dtcc.com/ThoughtLeadership/images/dtcc_banner_top_middle.jpg";, "http://www.dtcc.com/ThoughtLeadership/images/banner_topright.jpg","http://w ww.dtcc.com/ThoughtLeadership/images/thoughtmenu_r2_c3.jpg","http://www.dtcc .com/ThoughtLeadership/images/searcharrow.gif"); $new = array("http://www.dtcc.com/images/dtcc_banner_logo.gif";, "http://www.dtcc.com/images/dtcc_banner_top_middle.jpg";, "http://www.dtcc.com/images/banner_topright.jpg","http://www.dtcc.com/images /thoughtmenu_r2_c3.jpg","http://www.dtcc.com/images/searcharrow.gif";); $filename = str_replace($old, $new, $filename); echo $filename; echo "done"; ?> You would still have to replace the links to the full path instead of the relative path that it now has. The str_replace calls are kinda expensive IMHO, a good regex would be better (like I said in my last mail) another thing to note is sometimes the remote server times out or is too slow so the script times out... I hope this helped dude...will take down the page from there in a few hours. Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Chirantan Ghosh wrote: Hi Edward, I would simply like to print the remote Menu page( http://www.dtcc.com/ThoughtLeadership/menu.htm ) in a new page. I did the Error report print because I had no idea for what reason my PHP code was working. The menu is used as a header as well(the root file is JS which I can't use as I don't know all the directories of dtcc.com ) I am simply trying to impress a non technical person of the company so I can get a design contract. How can print the menu in different domain html pages? ( I would like to use PHP as server language) Thanks, Chirantan First try this: print htmlentities(file_get_contents('http://www.dtcc.com/ThoughtLeadership/menu.htm')); ?> That will let you see the HTML in your browser. If you don't get anything then either your request is being blocked by a firewall or you don't have fopen wrappers enabled. I'm betting on the latter though. Are you running a local install of php or through a remote server? You should be generating some kind of errors if your not getting anything back. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hey, The problem might be with your php settings, run phpinfo() and see if allow_url_fopen is set to ON heres where i uploaded what i did so far, little more needs to be done so that the mouseover images work: http://php-php.com/a2ztips/test.php The way I did it is in a *very very very dirty way*, I suggest you dump my code and use a RegEx there (am too lazy to write one) instead of the multiple str_replace calls but my code should give you a good starting point. http://www.dtcc.com/ThoughtLeadership/menu.htm'); $filename= str_replace("../dtcc.css","http://www.dtcc.com/dtcc.css";, $filename); $filename= str_replace("images/","http://www.dtcc.com/images/";, $filename); $filename= str_replace("/http:","http:", $filename); $filename= str_replace("..http:","http:", $filename); echo $filename; ?> Cheers, Ryan On 7/22/2005 6:11:27 PM, Chirantan Ghosh ([EMAIL PROTECTED]) wrote: > Hi Ryan, > > I tried that first & also after you wrote with no avail. ( This should be > > very elemental) > = > $filename = > file_get_contents('http://www.dtcc.com/ThoughtLeadership/menu.htm'); > echo $filename; > ?> > = > > I am trying this html in a local machine. I preview it Internet Explorer > (which has access to net). > Does it matter if the HTML file is not residing in a domain?( I > didn't think > so but no harm asking) > > Thanks a bunch for taking interest, > Chirantan > > ----- Original Message - > From: "Ryan A" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Cc: "php" > Sent: Friday, July 22, 2005 12:10 PM > Subject: Re: [PHP] how to post a question? > > > > Hey, > > Getting the code from the remote site is easy enough, you just gotto find > > the images now, but heres something > > that should get you the basic code including the javascript: > > > > > $filename = > > file_get_contents('http://www. > dtcc.com/ThoughtLeadership/menu.htm'); > > echo $filename; > > ?> > > > > once you have the code, start convert -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hi Ryan, I tried that first & also after you wrote with no avail. ( This should be very elemental) = http://www.dtcc.com/ThoughtLeadership/menu.htm'); echo $filename; ?> = I am trying this html in a local machine. I preview it Internet Explorer (which has access to net). Does it matter if the HTML file is not residing in a domain?( I didn't think so but no harm asking) Thanks a bunch for taking interest, Chirantan - Original Message - From: "Ryan A" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: "php" Sent: Friday, July 22, 2005 12:10 PM Subject: Re: [PHP] how to post a question? Hey, Getting the code from the remote site is easy enough, you just gotto find the images now, but heres something that should get you the basic code including the javascript: http://www.dtcc.com/ThoughtLeadership/menu.htm'); echo $filename; ?> once you have the code, start converting the relative image paths to full image paths, should work. Cheers, Ryan -- 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
Re: [PHP] how to post a question?
Hey, Getting the code from the remote site is easy enough, you just gotto find the images now, but heres something that should get you the basic code including the javascript: http://www.dtcc.com/ThoughtLeadership/menu.htm'); echo $filename; ?> once you have the code, start converting the relative image paths to full image paths, should work. Cheers, Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hi Edward, I would simply like to print the remote Menu page( http://www.dtcc.com/ThoughtLeadership/menu.htm ) in a new page. I did the Error report print because I had no idea for what reason my PHP code was working. The menu is used as a header as well(the root file is JS which I can't use as I don't know all the directories of dtcc.com ) I am simply trying to impress a non technical person of the company so I can get a design contract. How can print the menu in different domain html pages? ( I would like to use PHP as server language) Thanks, Chirantan - Original Message - From: "Edward Vermillion" <[EMAIL PROTECTED]> To: Cc: "Alan Milnes" <[EMAIL PROTECTED]> Sent: Friday, July 22, 2005 11:20 AM Subject: Re: [PHP] how to post a question? Chirantan Ghosh wrote: Hi Alan & Everybody who wasted time to read my 1st Letter, SORRY guys, I do deserve the scorn but it was genuine mistake I didn't want to post garbage bugging other people. I was under the impression that I was mailing to the HELP DESK( nonliving resp system). If you can, Please do help me in my real PHP issue: === I am trying to print a remote header menu in a html page without frames. The client side JS in located in this htm. ( http://www.dtcc.com/ThoughtLeadership/menu.htm ) I tried both INCLUDE, REQUIRE with no avail. I am a complete novice beginner so can anyone help me a bit please? The code I tried: == TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0> http://www.dtcc.com/ThoughtLeadership/menu.htm'; print getRandomLine($filename); function getRandomLine($filename) { global $errors; if (file_exists($filename)) { mt_srand ((double) microtime() * 100); $lines = file($filename); $line_number = mt_rand(0,sizeof($lines)-1); return $lines[$line_number]; } else { $errors['getRandomLine'][] = "File: $filename not found"; return FALSE; } } ?> ...& On it Goes Can you please let me know why can't print the remote HTM in the current page (Though it is in a different domain)? Thanks, Chirantan NYC - Original Message - From: "Alan Milnes" <[EMAIL PROTECTED]> Cc: Sent: Friday, July 22, 2005 10:47 AM Subject: Re: [PHP] how to post a question? Chirantan Ghosh wrote: I was wondering how can I ask a question to the other subscribers? Try reading this first:- http://www.catb.org/~esr/faqs/smart-questions.html Alan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just out of curiosity, why are you just printing a random line from the file? Then the next question is do you have your error reporting turned up: error_reporting(E_ALL); and display_errors = On in php.ini, only for a development server, or at least a log file to look at, for a production server? I'm going to assume that you've checked the source of your script output and the random line isn't where you thout it would be? The best thing to do would be to just print out the lines/files you are trying to get, without the rest of the HTML, to see what your getting from just the part your having trouble with. -- 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
Re: [PHP] how to post a question?
You just did it On 7/22/05, Chirantan Ghosh <[EMAIL PROTECTED]> wrote: > > I was wondering how can I ask a question to the other subscribers? > >
Re: [PHP] how to post a question?
> Posting a question on how to post a question. Here it goes: http://www.collectionscanada.ca/obj/h9/f1/284-v3.jpg Just put your hand on top of it and say "ABRACADABRA" Nadim Attari -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Chirantan Ghosh wrote: Hi Alan & Everybody who wasted time to read my 1st Letter, SORRY guys, I do deserve the scorn but it was genuine mistake I didn't want to post garbage bugging other people. I was under the impression that I was mailing to the HELP DESK( nonliving resp system). If you can, Please do help me in my real PHP issue: === I am trying to print a remote header menu in a html page without frames. The client side JS in located in this htm. ( http://www.dtcc.com/ThoughtLeadership/menu.htm ) I tried both INCLUDE, REQUIRE with no avail. I am a complete novice beginner so can anyone help me a bit please? The code I tried: == http://www.dtcc.com/ThoughtLeadership/menu.htm'; print getRandomLine($filename); function getRandomLine($filename) { global $errors; if (file_exists($filename)) { mt_srand ((double) microtime() * 100); $lines = file($filename); $line_number = mt_rand(0,sizeof($lines)-1); return $lines[$line_number]; } else { $errors['getRandomLine'][] = "File: $filename not found"; return FALSE; } } ?> ...& On it Goes Can you please let me know why can't print the remote HTM in the current page (Though it is in a different domain)? Thanks, Chirantan NYC - Original Message - From: "Alan Milnes" <[EMAIL PROTECTED]> Cc: Sent: Friday, July 22, 2005 10:47 AM Subject: Re: [PHP] how to post a question? Chirantan Ghosh wrote: I was wondering how can I ask a question to the other subscribers? Try reading this first:- http://www.catb.org/~esr/faqs/smart-questions.html Alan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Just out of curiosity, why are you just printing a random line from the file? Then the next question is do you have your error reporting turned up: error_reporting(E_ALL); and display_errors = On in php.ini, only for a development server, or at least a log file to look at, for a production server? I'm going to assume that you've checked the source of your script output and the random line isn't where you thout it would be? The best thing to do would be to just print out the lines/files you are trying to get, without the rest of the HTML, to see what your getting from just the part your having trouble with. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Hi Alan & Everybody who wasted time to read my 1st Letter, SORRY guys, I do deserve the scorn but it was genuine mistake I didn't want to post garbage bugging other people. I was under the impression that I was mailing to the HELP DESK( nonliving resp system). If you can, Please do help me in my real PHP issue: === I am trying to print a remote header menu in a html page without frames. The client side JS in located in this htm. ( http://www.dtcc.com/ThoughtLeadership/menu.htm ) I tried both INCLUDE, REQUIRE with no avail. I am a complete novice beginner so can anyone help me a bit please? The code I tried: == http://www.dtcc.com/ThoughtLeadership/menu.htm'; print getRandomLine($filename); function getRandomLine($filename) { global $errors; if (file_exists($filename)) { mt_srand ((double) microtime() * 100); $lines = file($filename); $line_number = mt_rand(0,sizeof($lines)-1); return $lines[$line_number]; } else { $errors['getRandomLine'][] = "File: $filename not found"; return FALSE; } } ?> ...& On it Goes Can you please let me know why can't print the remote HTM in the current page (Though it is in a different domain)? Thanks, Chirantan NYC - Original Message - From: "Alan Milnes" <[EMAIL PROTECTED]> Cc: Sent: Friday, July 22, 2005 10:47 AM Subject: Re: [PHP] how to post a question? Chirantan Ghosh wrote: I was wondering how can I ask a question to the other subscribers? Try reading this first:- http://www.catb.org/~esr/faqs/smart-questions.html Alan -- 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
Re: [PHP] how to post a question?
Chirantan Ghosh wrote: I was wondering how can I ask a question to the other subscribers? Try reading this first:- http://www.catb.org/~esr/faqs/smart-questions.html Alan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
> I was wondering how can I ask a question to the other subscribers? Dude, when you figure it out let me know too... :-p -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Shaw, Chris - Accenture wrote: Posting a question on how to post a question. :) you gotta start somewhere -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] how to post a question?
Posting a question on how to post a question. :) -Original Message- From: Chirantan Ghosh [mailto:[EMAIL PROTECTED] Sent: 22 July 2005 14:56 To: php-general@lists.php.net Subject: [PHP] how to post a question? * This e-mail has been received by the Revenue Internet e-mail service. * This message has been delivered to the Internet by the Revenue Internet e-mail service * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to post a question?
Chirantan Ghosh wrote: I was wondering how can I ask a question to the other subscribers? Don't look know but, you just did. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to post a question?
I was wondering how can I ask a question to the other subscribers?