如何在添加文本“Uhr”的String中设置第三个运算符?

问题描述 投票:0回答:3

我需要在以下代码的末尾添加“Uhr”:

<?
$doc = JFactory::getDocument();
            $doc->setTitle($event->title . " | Example");
            $doc->setDescription($event->title . " am " . $event->start, 'end' -> $event->end "uhr needs to be here");
?>

我该如何存档?因为如果我添加一个.“Uhr”它不起作用:(

php string joomla operator-keyword
3个回答
1
投票
$doc->setDescription($event->title . " am " . $event->start . ", " . $event->end . " Uhr");

应该这样做。

格式化日期:

$doc->setDescription($event->title . " am " . date('d.m.Y', strtotime($event->start)) . ", " . date('H:i', strtotime($event->end)) . " Uhr");

0
投票

我认为最后的->有问题。也许这有效:

$doc->setDescription($event->title . " am " . $event->start, 'end' . $event->end . "uhr");

0
投票

"am""end""urh needs to be here"的情况下,最好使用相同的引号,如:

<?
$doc = JFactory::getDocument();
$doc->setTitle($event->title . " | Tanzschule Hartung");
$doc->setDescription($event->title . " | Tanzschule Hartung" " am " . $event->start, "end" -> $event->end . "uhr needs to be here");
?>

(看看你的文字'结尾',与上面的代码相比)

看起来$event->start(和其他人)需要显示一些请求的文本。

从另一个函数请求文本后,为什么需要使用.(点)是因为PHP需要了解何时必须显示文本。

.是字符串连接运算符。

这可能也有效:

<?
$doc = JFactory::getDocument();
// Setting titles
$title = $doc->setTitle($event->title);
$start = $event->start;
$end   = $event->end;

$doc->setDescription($title . " | Tanzschule Hartung am " . $start . " , end" . $end . "uhr needs to be here");
?>

我希望这可以解决一些问题。

如果您有任何问题随时问。

© www.soinside.com 2019 - 2024. All rights reserved.