如果在php中选择和播放来自两个选项的iframe [关闭]
问题描述:
I want to add an auto select one iframe
"which is running" between two to play videos on my website.
I need decision block in PHP/JavaScript to automatically choose 1 iframe
from the two.
In some countries the videos plays from one iframe
and in other countries it plays from both iframes.
So I want to add a way so any user from anywhere can watch videos.
Normally I'm using this one directly
<div id="video" style="margin-top:10px;"><iframe width="940" height="420" src="http://www.youtube.com/embed/<?php echo $_GET['v'] ;?>?autoplay=1&vq=medium&modestbranding=1&showinfo=0" frameborder="0" allowfullscreen></iframe>
But now I want to add one more iframe
, which is here
<div id="video" style="margin-top:10px;"><iframe width="940" height="420" src="http://www.v.ytapi.com/embed/<?php echo $_GET['v'] ;?>?autoplay=1&vq=medium&modestbranding=1&showinfo=0" frameborder="0" allowfullscreen></iframe>
plz help me. thanks, Medipalace
答
You can find many responses to know the country in this post: PHP - Detect country
For example you can use the api hostip
$country = '';
$IP = $_SERVER['REMOTE_ADDR'];
if (!empty($IP)) {
$country = file_get_contents('http://api.hostip.info/country.php?ip='.$IP);
}
After you can test the country : if($country== "england") { // your code }