只从句子中提取并显示第一个单词

时间:2013-11-09 21:16:38

标签: php

我有两页index.php和currentmovies.php。我试图在currentmovies.php中显示给定电影的电影名称,但我无法显示整个名称,只显示第一个单词。我在index.php中写了我的查询,并将值传递给currentmovies.php。

例如:如果电影名称为“指环王”,则仅显示“主”

// index.php中的代码     echo“”;

//code in currentmovies.php
<?php 
echo "<b><font size='3'>Current Movie:",$_GET['movie_name']," </font></b>";

echo "<p> The movie ",$_GET['movie_name']," was released on ",$_GET['rdate']," and falls under the ",$_GET['genre']," category. </p>";

感谢您的帮助

2 个答案:

答案 0 :(得分:0)

//code in currentmovies.php
<?php 
echo "<b><font size='3'>Current Movie: ".$_GET['movie_name']."</font></b>";

echo "<p>The movie ".$_GET['movie_name']." was released on ".$_GET['rdate']." and falls under the ".$_GET['genre']." category.</p>";

试试这个:

答案 1 :(得分:-1)

请这样做:

<?php 
   echo '<b><font size="3">Current Movie: '.$_GET['movie_name'].' </font></b>';
   echo '<p> The movie '.$_GET['movie_name'].' was released on '.$_GET['rdate'].' and falls under the '.$_GET['genre'].' category. </p>';

请记住,在这种情况下是点而不是逗号。

还有一件事: 如果您没有在配额内使用任何变量,请使用单个配额,加上html更好更容易使用单个配额,例如:

 <font size="3">