Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Kak izmenit parametr objekta?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian
View previous topic :: View next topic  
Author Message
dazfx
Smarty n00b


Joined: 29 Apr 2011
Posts: 1

PostPosted: Fri Apr 29, 2011 9:05 pm    Post subject: Kak izmenit parametr objekta? Reply with quote

Dopustim, est object s paramerom id.
{$category->id}
Kak prisvoit parametru id znachenie, 2, naprimer.
Back to top
View user's profile Send private message
StockShop
Smarty n00b


Joined: 11 May 2011
Posts: 1

PostPosted: Wed May 11, 2011 12:19 pm    Post subject: Reply with quote

Poprobuj prosto $category->id=2;
Back to top
View user's profile Send private message Visit poster's website
0r10n
Smarty n00b


Joined: 15 Jul 2011
Posts: 3

PostPosted: Fri Jul 15, 2011 6:38 am    Post subject: Reply with quote

StockShop wrote:
Poprobuj prosto $category->id=2;


Этот способ подойдёт если тип переменной в объекте стоит PUBLIC.
Если же PRIVATE или PROTECTED то нужно писать свою функцию в классе или же описывать всё через встроенную функцию __set();.

элементарный пример
class bla
{
protected $id;

//куча кода

public function SetID($var)
{
$this->id=$var;
}
//ещё куча кода
}

$bla= new bla();
$bla->SetID("данные");

PS: А если честно то это элементарные основы классов которые описаны в каждой нормальной книге по PHP. Не поленитесь изучить и мир станет проще. Wink
Back to top
View user's profile Send private message
dimono
Smarty n00b


Joined: 23 Nov 2013
Posts: 1
Location: http://manlife.su

PostPosted: Sat Nov 23, 2013 6:59 pm    Post subject: Reply with quote

0r10n wrote:
StockShop wrote:
Poprobuj prosto $category->id=2;


Этот способ подойдёт если тип переменной в объекте стоит PUBLIC.
Если же PRIVATE или PROTECTED то нужно писать свою функцию в классе или же описывать всё через встроенную функцию __set();.

элементарный пример
class bla
{
protected $id;

//куча кода

public function SetID($var)
{
$this->id=$var;
}
//ещё куча кода
}

$bla= new bla();
$bla->SetID("данные");

PS: А если честно то это элементарные основы классов которые описаны в каждой нормальной книге по PHP. Не поленитесь изучить и мир станет проще. Wink


тоже пригодилось, благодарю Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Russian All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP