This works just fine: echo myfunction(); Code (markup): Then why wont this work? $page = 'http://www.yadayada.com/yada?v='.myfunction().''; echo $page; Code (markup): I have also tried $blah = myfunction(); $page = 'http://www.yadayada.com/yada?v='.$blah.''; echo $page; Code (markup): Still no wanna work. In all cases all that happens is that the function doesn't get echoed at all. It doesn't display an error or anything, it just wont display. What gives?
well, I was echoing inside the function -- and I figured that you just can't use a function inside fopen, so what I did is make it not a function, and instead just plain code. Then I tried echoing the variable that I wanted and it still does the same thing. So it's not that I can't use a function inside fopen. I will explain here is my entire code (has a lot of includes and (edit outs (because I am working on it)), hope you can read between the lines) <? $lines = file($_SERVER['DOCUMENT_ROOT'] . '/videos/'.$_GET['v'].'.txt'); $line_amount = count($lines); #echo '<pre>'; print_r($lines); echo '</pre>'; $perpage = 1; $p = isset($_GET['p']) ? $_GET['p'] : 1; for ($i = (($p * $perpage) - $perpage); $i <= (($perpage * $p) - 1); $i++){ if($i >= $line_amount){ break; } else{ if($lines[$i] != ''){ $current_video_id = $lines[$i]; } } } ?> <? $video_code = $_GET['v']; include $_SERVER['DOCUMENT_ROOT'] . '/videos/'.$video_code.'-config.php'; ?> <? #echo $current_video_id; #GET THE title #$page = 'http://www.youtube.com/watch?v=XLh4-XTnXq8'; $page = 'http://www.youtube.com/watch?v='.$current_video_id.''; echo urlencode($page); $start = '<title>'; $end = '<\/title>'; $fp = fopen($page, 'r' ); $cont = ""; while( !feof( $fp ) ) { $buf = trim( fgets( $fp, 4096 ) ); $cont .= $buf; } preg_match( "/$start(.*)$end/s", $cont, $match ); $video_title = $match[ 1 ]; ?> Code (markup): THIS WORKS $page = 'http://www.youtube.com/watch?v=XLh4-XTnXq8'; THIS DOESN'T WORK $page = 'http://www.youtube.com/watch?v='.$current_video_id.''; Note: echo $current_video_id works! Then why wont it work in my fopen? ie: $current_video_id returns XLh4-XTnXq8 -- so why doesn't it work in fopen? Note: I know that the fopen can read the variable because it is displaying the intended URL in the error: http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXLh4-XTnXq8%0A Warning: fopen(): HTTP request failed! HTTP/1.1 400 Bad Request in c:\documents and settings\administrator\my documents\my websites\_practice\www\display.php on line 33 Warning: fopen(http://www.youtube.com/watch?v=XLh4-XTnXq8 ): failed to open stream: No error in c:\documents and settings\administrator\my documents\my websites\_practice\www\display.php on line 33
Blatantly false. Please put: var_dump($current_video_id); Code (markup): above the $page variable. Jay