php - Hyperlinks do not get proper value -
i have php script has infinite loop in it. browser not print first echo statements in loop, not provide proper links hyperlinks. have gone wrong?
code:
<html> <head> <style> img{ height:200px; width:200px; } </style> </head> <body> <?php error_reporting (0); set_time_limit(0);// setting infinite timeout limit. for($i=1; ;$i++) { $to_send = "http://graph.facebook.com/"; $to_send_new = $to_send.$i; $content = file_get_contents($to_send_new); $parsed = json_decode($content); $link = $parsed->link; $link = str_replace("http://www.facebook.com","https://graph.facebook.com",$link); $link .="/picture?width=200&height=200"; if(!$parsed->first_name) goto a; ?> <br> first name: <?php echo $parsed->first_name;?> <br> last name:<?php echo $parsed->last_name;?> <br> full name :<?php echo $parsed->name;?> <br> facebook username:<?php echo $parsed->username;?> <br> gender:<?php echo $parsed->gender;?> <br> <a href="<?php echo $link; ?>" target="_blank">profile picture</a> <!-- <img src="<?php/* echo $link; */?>" > --> <br> <hr> <?php sleep(5); a: } ?> </body> </html>
be careful infinite loops. depending on web server (eg. apache) , php settings request server adds thread on server, eats set of ressources. may or may not hang server on time.
sometimes use long lasting loops myself. in such cases found apachestatus useful, check threads still running: http://httpd.apache.org/docs/2.2/mod/mod_status.html
it provides pid helps kill old threads.
Comments
Post a Comment