2013-11-02 12 views
1

我需要一個代碼,當我得到http://www.youtube.com/watch?v=ktvTqknDobU這PHP腳本重命名爲http://bloxhotel.nl/video?watch=ktvTqknDobU改變輸入鏈接如何做到這一點?

而做到這一點載荷頁之後。

對不起,我的英語不好。

我已經試過這

<form action="welcome_get.php" method="get"> 
Youtube Link: <input type="text" name="link"><br> 

<input type="submit"> 
</form> 

<?php 
ob_start(); 
include 'includes/inc.bootstrap.php'; 
$page = Array(
    'title' => ((isset($user)) ? $user->username : ''), 
    'onload' => ((isset($_GET['utm_source']) && $_GET['utm_source'] == 'welcome') ? 'Pixel.View.OpenUrlOverlay(\'/pixlett/Video.php\');' : ''), 
    'tab' => Array('me', 'home'), 'access' => Array(true, false) 
); 
include 'content/header.php'; 
include 'content/menu.php'; 
?> 

<?php echo htmlspecialchars($_POST['link']); ?> 
+0

該網頁還需要重新加載到該鏈接 –

回答

0

使用str_replace()功能

$youtube = "http://www.youtube.com/watch?v=ktvTqknDobU"; 
$link = str_replace("http://www.youtube.com/watch?v=","http://bloxhotel.nl/video?watch=",$youtube); 


使用<a href>的鏈接。

echo "<a href='$link'>Video Link</a>"; 
+0

的頁面必須爲http:// bloxhotel .nl/video?watch = ktvTqknDobU –

+0

@MikeSant檢查答案,當您點擊視頻鏈接時,它會將您重定向到頁面 –

0

您可以使用str_replace()函數PHP內置功能,

$link = "http://www.youtube.com/watch?v=ktvTqknDobU"; 

$match = "http://www.youtube.com/watch?v="; 

$tobeReplaced = "http://bloxhotel.nl/video?watch="; 

echo $RequiredLink = str_replace($match, $tobeReplaced, $link); 

編號:http://php.net/manual/en/function.str-replace.php