开发者

Getting echo within echo to work together

In a little trouble with this, is they any way i can get to echo's working together see code below,

<?php $youtube_vimeo_player = get_post_meta($post->ID,'_youtube_vimeo_player',TRUE); ?>

<?php echo $video->embed(' <?php echo $youtube_vimeo_player['url']; ?> ', '', 开发者_JAVA技巧''); ?>

I'm wanting the info brought from the vimeo_player url to be entered into the video->embed section. Any help on this would much be appreciated : )


try it like this:

<?php $youtube_vimeo_player = get_post_meta($post->ID,'_youtube_vimeo_player',TRUE); ?>

<?php echo $video->embed( $youtube_vimeo_player['url'], '', ''); ?>


Replace

' <?php echo $youtube_vimeo_player['url']; ?> '

with

"{$youtube_vimeo_player['url']}"

You dont need echoing inside the php string. Note that { and } are the special way to embed array index, or object method call into the string, they are not present in final string.

Btw, it's sufficient to just do

echo $video->embed($youtube_vimeo_player['url'], '', ''); 

As $youtube_vimeo_player['url'] already shoud be the string


<?php echo $video->embed("'".$youtube_vimeo_player['url']."'", '', ''); ?>


PHP isn't that crazy, but thanks for remembering us it could seem to.

Thou shall write:

<?php
  $youtube_vimeo_player = get_post_meta($post->ID,'_youtube_vimeo_player',TRUE);
  $url=$youtube_vimeo_player['url'];
  $video->embed($url, '', '');
?>

Educate yourself on the concept of variable, and remember, php has only one level of embedding (that is one level of <?php ... ?> — no nesting)

And believe it, it's better this way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜