Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8646019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:41:49+00:00 2026-06-12T12:41:49+00:00

I have a class like below: $structure = new stdClass(); $structure->template->view_data->method = ‘get_sth’; $structure->template->view_data->lang

  • 0

I have a class like below:

$structure = new stdClass();

$structure->template->view_data->method       = 'get_sth';
$structure->template->view_data->lang         = $lang;
$structure->template->view_data->id_page      = $id_page;
$structure->template->view_data->media_type   = 'ibs';
$structure->template->view_data->limit        = '0';
$structure->template->view_data->result_type  = 'result';

And I am curious about if it can be written like below?

$structure->template->view_data->method       = 'get_sth_else',
                               ->lang         = $lang,
                               ->id_page      = $id_page,
                               ->media_type   = 'ibs',
                               ->limit        = '0',
                               ->result_type  = 'result',

                    ->another-data->method    = 'sth_else',
                                  ->type      = 'sth',
                                  ->different = 'sth sth';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:41:50+00:00Added an answer on June 12, 2026 at 12:41 pm

    What you are talking about is called a ‘Fluent Interface‘, and it can make your code easier to read.

    It can’t be used ‘out of the box’, you have to set up your classes to use it. Basically, any method that you want to use in a fluent interface must return an instance of itself. So you could do something like:-

    class structure
    {
        private $attribute;
        private $anotherAttribute;
    
        public function setAttribute($attribute)
        {
            $this->attribute = $attribute;
            return $this;
        }
    
        public function setAnotherAttribute($anotherAttribute)
        {
            $this->anotherAttribute = $anotherAttribute;
            return $this;
        }
    
        public function getAttribute()
        {
            return $this->attribute;
        }
    
        //More methods .....
    }
    

    and then call it like this:-

    $structure = new structure();
    $structure->setAttribute('one')->setAnotherAttribute('two');
    

    Obviously, this will not work for getters, as they must return the value you are looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class structure like below. ObservableCollection<Group> deviceCollection = new ObservableCollection<Group>(); public class
I have a xml that looks like below <xsl:template match=//xml> <xsl:for-each select=//z:row> <ul class
i have a t_my_class table structure like below (MySql table) id class group age
I have class like this below shown. which contains the shopping items where the
I have a class like the one below: class Foo { private: std::map<std::string, Bar*>
If I have a class that looks like below, how to I pull out
Say I have a simple address class like below: public class Address { public
i have a model say modela with a calculate field. like below class modelA
I have a Model which has some constants defined, like below: class Order(models.Model): WAITING
Say I have a class with three constructors, like the one below: public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.