blacktiger786 Posted July 16, 2014 Share Posted July 16, 2014 i have this code which fetch meta tags and title function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $data = curl_exec($ch); curl_close($ch); return $data; } $html = file_get_contents_curl("http://example.com/"); //parsing begins here: $doc = new DOMDocument(); @$doc->loadHTML($html); $nodes = $doc->getElementsByTagName('title'); //get and display what you need: $title = $nodes->item(0)->nodeValue; $metas = $doc->getElementsByTagName('meta'); for ($i = 0; $i < $metas->length; $i++) { $meta = $metas->item($i); if($meta->getAttribute('name') == 'description') $description = $meta->getAttribute('content'); if($meta->getAttribute('name') == 'keywords') $keywords = $meta->getAttribute('content'); } if(!title == ' ') { echo ' found a title'; } in this code you see in last i have if condition (!title==' ') its execute it when i open file i want its only run when i click the html button like <input type="button" name="Release" onclick="" value="Click "> please tell me what i do help me Link to comment https://forums.phpfreaks.com/topic/289943-need-some-help-of-onclick-button-in-php/ Share on other sites More sharing options...
Psycho Posted July 16, 2014 Share Posted July 16, 2014 The above is PHP code. But, that condition is invalid - you are missing the dollar sign at the beginning of the variable name: $title Plus, to do something "onclick" requires that you either submit the page and process the POST/GET data or you need to implement JavaScript to perform an AJAX request. I assume you want the latter. But, there's too much to try and tell you how to do this in a forum post. I would suggest you look up on how to implement JQuery's AJAX functionality. Link to comment https://forums.phpfreaks.com/topic/289943-need-some-help-of-onclick-button-in-php/#findComment-1485470 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.