本文整理汇总了PHP中Tweet::CreateTweet方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::CreateTweet方法的具体用法?PHP Tweet::CreateTweet怎么用?PHP Tweet::CreateTweet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::CreateTweet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
</body>
<?php
require_once "./src/connection.php";
if (isset($_GET["userId"])) {
$userId = $_GET["userId"];
} else {
$userId = $_SESSION['userId'];
}
$userToShow = User::GetUserById($userId);
if ($userToShow !== FALSE) {
echo "<h1>{$userToShow->getName()}</h1>";
echo "\n <h3>Nowy tweet:</h3>";
$tweet_text = $_POST["tweet_text"];
if ($tweet_text !== FALSE) {
$tweet1 = Tweet::CreateTweet($userId, $tweet_text, date("Y/m/d"));
}
echo "\n <form action='showUser.php' method='post'>\n <input type='text' name='tweet_text'>\n <input type='submit'>\n </form>";
echo "<h3>Posty uzytkownika:</h3>";
$tweets = $userToShow->loadAllTweets();
foreach ($tweets as $tweet) {
echo "<hr>";
echo "{$tweet->getText()}<br>";
echo "<a href='showTweet.php?tweetId={$tweet->getId()}'>Show</a><br>";
}
}
?>
示例2: foreach
}
if (isset($_GET['userId'])) {
$userId = $_GET['userId'];
} else {
$userId = $_SESSION['userId'];
}
$userToShow = User::GetUserById($userId);
if ($userToShow !== FALSE) {
if ($userToShow->getId() !== $_SESSION['userId']) {
echo "<h1>{$userToShow->getName()}</h1>";
}
if ($userToShow->getId() === $_SESSION['userId']) {
echo "<h1>Witaj {$userToShow->getName()}</h1>";
echo "\n <a href='AllMessages.php?userId={$userToShow->getId()}'>Twoje wiadomosci</a>\n <br><br>";
if ($_SERVER['REQUEST_METHOD'] === "POST") {
$tweet = Tweet::CreateTweet($_SESSION['userId'], $_POST['tweet_text']);
if ($tweet === FALSE) {
echo "Nieprawidlowy wpis.<br>";
}
}
echo "\n <form action='ShowUser.php' method='POST'>\n <label>Dodaj Tweet'a:</label>\n <input type='text' name='tweet_text''>\n <input type='submit'>\n </form>\n ";
}
foreach ($userToShow->loadAllTweets() as $tweet) {
echo "{$tweet->getText()} | Komentarze: {$tweet->numberOfComments()} | ";
echo "<a href='ShowTweet.php?tweetId={$tweet->getId()}'>Show info</a><br>";
}
if ($userToShow->getId() !== $_SESSION['userId']) {
echo "\n <form action='ShowUser.php?userId={$userToShow->getId()}' method='POST'>\n <label>Wyslij wiadomosc:</label>\n <input type='text' name='message_text''>\n <input type='submit'>\n </form>\n ";
if ($_SERVER['REQUEST_METHOD'] === "POST") {
$message = Message::CreateMessage($_SESSION['userId'], $userToShow->getId(), $_POST['message_text']);
if ($message === FALSE) {
示例3: header
<?php
require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
header("Location: login.php");
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (strlen(trim($_POST['tweet_text'])) > 0) {
$tweetText = $_POST['tweet_text'];
$tweet = Tweet::CreateTweet($tweetText);
header("Location: indeks.php");
} else {
echo "Nie udało się utworzyć tweeta :(";
}
}
$userId = $_SESSION['userId'];
$userToShow = User::GetUserById($userId);
$allTweets = $userToShow->getAllFriendsAndMineTweets();
//var_dump($allTweets);
echo "<h1> Tweety Twoje oraz twoich przyjaciół </h1>";
if ($userToShow->getId() === $_SESSION['userId']) {
?>
<h3>Nowy tweet</h3>
<form action='showUser.php' method='post'>
<label>
<input type='text' name='tweet_text'>
</label>
<input type='submit'>
</form>
<?php