2014-10-30 117 views
-3

PHP內容如何形成重定向到動態內容的動態URL重定向到動態URL在URL

我在PHP模式回聲字符串開頭,我想在字符串變量

我很抱歉,如果它不明確。我新的PHP我最近在網頁設計 改寫的問題,因爲這發現intrest服務器和網絡的工作是第一次 我正在註冊爲第一次的論壇最近。現在我學會了如何顯示代碼。 我正在學習PHP的愛好這是我爲自己做的一個項目。學習

<a href="modify_pages.php?pages=<?php echo urlencode($current_pages["id"]); ?>"> modify Page</a> 

工作正常,但只複製示例代碼保持簡單我不知道有關問題的長度 如果我應該進入整個代碼,請讓我知道未來如果reqiured進入 全代碼

<?php 
//current page id and current Step id is data from sql database table for this page 

function redirect_to($new_location) { 
      header("Location: ".$new_location); 
       exit; 
    } 

if ($some_var1==$some_var2) 
    { 
     redirect_to("edit_pages.php?pages=<?php echo urlencode($current_step["id"])?>"); 
    } else { 
    redirect_to("edit_pages.php?pages=<?php echo urlencode($current_pages["id"])?>"); 

?> 

我面臨的基本問題是是否有可能使用phptag或腳本邏輯在引號 「」

HTML「;?>

PHP」 HTML「PHP」「嵌套PHP和HTML

我真的尋求幫助(解決方法) 因爲如果我們可以使用PHP邏輯的報價,這將有助於我很縮短未來

不知道我的代碼如何使這項工作請幫助我與這個感謝所有幫助

回答

0

嘗試這樣。

<?php 
    $variable = 'Maths'; 
?> 
form_page.php?subject=<?php echo $variable; ?> 

輸出將是

form_page.php?subject=Maths 
+0

功能我使用重定向已經在PHP模式\t \t \t $消息=「頁面更新失敗在這裏,在這個地方」; \t \t \t redirect_to(「new_pages.php?some variables ..」); – 2014-10-30 09:38:45

+0

那又如何?看起來你的方法不工作......你的問題是什麼? – jAC 2014-10-30 09:55:02