how to check if url exists |
how to check if URL exists with codeigniter ?
I didn't find and try to do it with simple php but it is not as easy as I read. Maybe because php change and what works 10 years ago does not work today in 2025 with php 8 (I forget the decimal) I try curl_init($url)) $headers = get_headers($url); and differents easy solution but when I really check it it accept that it should not or I got php error message Do codeigniter have already done solution ? I even try if ( file_get_contents($url, 'FILE_TEXT', NULL, 0, 1)) But I got this kind of error file_get_contents(): php_network_getaddresses: getaddrinfo for aaaaaaa failed: Temporary failure in name resolution instead of true false I try catch but always have erors impossible to say if I have any kind of error it is false
CodeIgniter 4.6
lets re-phrase the question.
if someone enters a URL like : domain.com/elephant does that URL cause an event like loading a view or does something else; id that what you mean ? for a view you can do something in a controller like Code: public function showView($page) rout to pick up is : Code: $routes->get('(:any)','Pages::showView/$1');
How to check the existence of URL in PHP?
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |