如何在现有回声中回显iframe

问题描述 投票:0回答:1

我想在已经存在的echo($ loop)中回显iframe($ test2)但是当我这样做时我的网站没有加载。

问题出在哪儿?

我认为这与echoecho问题上有关。

<?php
function sac_getData($sac_lastID) {
	
	global $wpdb, $table_prefix, $sac_lastID, $sacGetChat;
	
	$loop = ''; 
	
	if (isset($_GET['sac_nonce_receive']) && wp_verify_nonce($_GET['sac_nonce_receive'], 'sac_nonce_receive')) {
		
		if ((isset($sacGetChat) && $sacGetChat === 'yes') && (!empty($sac_lastID) && is_numeric($sac_lastID))) {
			
			$query = $wpdb->get_results("SELECT * FROM ". $table_prefix ."ajax_chat WHERE id > ". $sac_lastID ." ORDER BY id DESC", ARRAY_A);
			
			for ($row = 0; $row < 1; $row++) {
				
				if (isset($query[$row]) && !empty($query[$row]) && is_array($query[$row])) {
					
					$id   = isset($query[$row]['id'])   ? $query[$row]['id']   : '';
					$time = isset($query[$row]['time']) ? $query[$row]['time'] : '';
					$name = isset($query[$row]['name']) ? $query[$row]['name'] : '';
					$text = isset($query[$row]['text']) ? $query[$row]['text'] : '';
					$url  = isset($query[$row]['url'])  ? $query[$row]['url']  : '';
					
					$time = sac_time_since($time);
					
$user = get_user_by('slug', $name);
$X = get_user_meta( $user->ID, 'description', true);					
$test2 = echo '<iframe width="100" height="40" src="https://X.com/'.$X.'" scrolling="no" frameborder="0"></iframe>';					
				
					
					
$loop = $id .'---'. $test2 .'---'. $text .'---'. $time .' '. esc_html__('ago', 'X') .'---'. $url .'---';
					
				}
				
			}
			
		}
		
	}
	
	echo $loop;
	
}
add_action('init', 'sac_getData');
?>

我试过这个。

<?php
function sac_getData($sac_lastID) {
	
	global $wpdb, $table_prefix, $sac_lastID, $sacGetChat;
	
	$loop = ''; 
	
	if (isset($_GET['sac_nonce_receive']) && wp_verify_nonce($_GET['sac_nonce_receive'], 'sac_nonce_receive')) {
		
		if ((isset($sacGetChat) && $sacGetChat === 'yes') && (!empty($sac_lastID) && is_numeric($sac_lastID))) {
			
			$query = $wpdb->get_results("SELECT * FROM ". $table_prefix ."ajax_chat WHERE id > ". $sac_lastID ." ORDER BY id DESC", ARRAY_A);
			
			for ($row = 0; $row < 1; $row++) {
				
				if (isset($query[$row]) && !empty($query[$row]) && is_array($query[$row])) {
					
					$id   = isset($query[$row]['id'])   ? $query[$row]['id']   : '';
					$time = isset($query[$row]['time']) ? $query[$row]['time'] : '';
					$name = isset($query[$row]['name']) ? $query[$row]['name'] : '';
					$text = isset($query[$row]['text']) ? $query[$row]['text'] : '';
					$url  = isset($query[$row]['url'])  ? $query[$row]['url']  : '';
					
					$time = sac_time_since($time);
					
$user = get_user_by('slug', $name);
$test2 = get_user_meta( $user->ID, 'description', true);					
		
					
					
$loop = $id .'---'. <?php echo '<iframe width="100" height="40" src="https://X.com/'.$test2.'" scrolling="no" frameborder="0"></iframe>':?> .'---'. $text .'---'. $time .' '. esc_html__('ago', 'simple-ajax-chat') .'---'. $url .'---';
					
				}
				
			}
			
		}
		
	}
	
	echo $loop;
	
}
add_action('init', 'sac_getData');
?>
php iframe echo
1个回答
0
投票

你写:

$loop = $id .'---'. <?php echo '<iframe width="100" height="40" src="https://X.com/'.$test2.'" scrolling="no" frameborder="0"></iframe>':?> .'---'. $text .'---'. $time .' '. esc_html__('ago', 'simple-ajax-chat') .'---'. $url .'---';

你现在已经在PHP了。使用另一个PHP标记是没有意义的。另外,不清楚你要用“:?>”来完成什么。结肠有错。

消除这些问题并合并一些最终彼此相邻的字符串,结果如下:

$loop = $id .'---<iframe width="100" height="40" src="https://X.com/'.$test2.'" scrolling="no" frameborder="0"></iframe>---'. $text .'---'. $time .' '. esc_html__('ago', 'simple-ajax-chat') .'---'. $url .'---';
© www.soinside.com 2019 - 2024. All rights reserved.