Answer the question
In order to leave comments, you need to log in
Why does it swear at Using $this when not in object context?
Hi all!
I can’t understand what the error
is, there is a helper, code:
<?php
namespace common\helpers;
use Yii;
class LastActivity
{
private $userid;
public function init()
{
$this->userid = Yii::$app->user->isGuest ? false : Yii::$app->user->identity->id;
}
static public function get()
{
return $this->userid;
}
}
<?php
use common\helpers\LastActivity;
?>
<?= LastActivity::get(1); ?>
Answer the question
In order to leave comments, you need to log in
^text\/\p{Cyrillic}(?:\S*?|\S*\s\S*)\p{Cyrillic}$
The third line does not end with Cyrillic, it ends with a number.
by the way, instead of \p{Cirillic} it's easier to write [а-яё] and put ui modifiers to ignore case. Just a shorter entry.
UPD: what the author ultimately needs after text/
:
1) only Cyrillic
2) not the first, not the last character and no more than 1 time can come across: space, apostrophe, dash.
I did not find another option, but I made a decision.
And what should $this be equal to when calling a static class method? An instance is not created with such a call.
static public function get()
{
return self::userid;
}
It considers $this to be an object.
What's in $this?
var_dump() is possible?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question