感謝您的快速響應!雖然下面的代碼看起來像我想打印的值在屏幕上查看我需要的值例如。 $ user_profile [email]在另一個函數中(註冊新的wordpress用戶)。以下是完整的代碼。我該怎麼做呢?指定一個返回(值)到一個新變量
<?php
try{
include_once "src/fbaccess.php";
}catch(Exception $e){
error_log($e);
}
try{
require_once "wp-blog-header.php";
}catch(Exception $e){
error_log($e);
}
try{
require_once "wp-includes/registration.php";
}catch(Exception $e){
error_log($e);
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Florian's Facebook login</title>
</head>
<body>
<!-- Copy the below code to display FB Login/Logout button -->
<?php if ($user): ?>
<a href="<?php echo $logoutUrl; ?>">Logout</a>
<?php else: ?>
<div>
<a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
</div>
<?php endif ?>
<!-- Copy the above code to display FB Login/Logout button -->
<h3>PHP Session</h3>
<pre><?php print_r($_SESSION); ?></pre>
<?php if ($user): ?>
<h3>You</h3>
<img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
<h3>Your User Object (/me)</h3>
<pre><?php return ($user_profile [email]); ?></pre>
<pre><?php return ($user_profile [first_name]); ?></pre>
<pre><?php return ($user_profile [last_name]); ?></pre>
<pre><?php return ($user_profile [location]); ?></pre>
<?php else: ?>
<strong><em>You are not Connected.</em></strong>
<?php endif ?>
你使用'return'做什麼?你很可能誤解了它的用途。 – zerkms
我使用return來獲取$ user_profile [email]的值,所以我可以在另一個函數中使用它。我不想打印價值。 –
你仍然不明白它是什麼。請參閱[文檔](http://php.net/return) – zerkms