garyed Posted yesterday at 12:20 AM Share Posted yesterday at 12:20 AM In trying to get the text off a particular website, I've used two different ways, both of which seem to work fine & give the exact same results.. I was wondering if anyone could give me any insight or recommendations why one way might be any better or worse than the other . I've used these two ways: $ch1=curl_init(); curl_setopt($ch1,CURLOPT_URL,$link1); curl_setopt($ch1,CURLOPT_RETURNTRANSFER, true); $text1=curl_exec($ch1); // or $text1 = shell_exec('curl '.$link1 ); The second way seems easier & speedwise they both are about the same I've also tried "file_get_contents" which also gives the same results but is obviously slower. Quote Link to comment https://forums.phpfreaks.com/topic/327110-cant-decide-which-curl-to-use/ Share on other sites More sharing options...
gizmola Posted yesterday at 06:04 PM Share Posted yesterday at 06:04 PM 16 hours ago, garyed said: In trying to get the text off a particular website, I've used two different ways, both of which seem to work fine & give the exact same results.. I was wondering if anyone could give me any insight or recommendations why one way might be any better or worse than the other . I've used these two ways: $ch1=curl_init(); curl_setopt($ch1,CURLOPT_URL,$link1); curl_setopt($ch1,CURLOPT_RETURNTRANSFER, true); $text1=curl_exec($ch1); // or $text1 = shell_exec('curl '.$link1 ); The second way seems easier & speedwise they both are about the same I've also tried "file_get_contents" which also gives the same results but is obviously slower. The two ways are significantly different. The first way is the way you should do this. It uses the curl extension that is built into PHP. The 2nd way is creating a system shell and then executing a shell command that in your case happens to be the curl command. Many things could go wrong, and you will not have visibility into those issues. It is a less direct method, and doesn't have the same level of access to curl options and results. Quote Link to comment https://forums.phpfreaks.com/topic/327110-cant-decide-which-curl-to-use/#findComment-1652020 Share on other sites More sharing options...
garyed Posted 23 hours ago Author Share Posted 23 hours ago Thanks for the reply, That makes a lot of sense. Quote Link to comment https://forums.phpfreaks.com/topic/327110-cant-decide-which-curl-to-use/#findComment-1652024 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.