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 4249878
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:27:17+00:00 2026-05-21T04:27:17+00:00

Ok now i have another problem i want to send one or more variable

  • 0

Ok now i have another problem i want to send one or more variable from one function to another like this:

class test{

    var $text2;

    function text1($text1){ // This will catch "This is text" from $text variable.

        $text1 = $this -> text2; // Giving $text1 value to $text2 

        return $this -> text2; // Now here is the trouble i think, i want to send the variable to the next function that is text2(). How do i do that?

    }
    function text2($text2){ // Here is the place that says undefined variable i want the variable $text2 from function text1() to be called here.

        echo $text2; // Now the variable $text2 should echo "This is text".

    }
}

$test = new test();

$text1 = "This is text"; // Assigning value to the variable.

$test -> text1($text1); // Passing the variable as parameter in the function text1().

echo $test -> text2($text2); // Trying to display the value of $text2 that is "This is text".
  • 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-05-21T04:27:18+00:00Added an answer on May 21, 2026 at 4:27 am

    @authors of most other answers: why do you just take bad code and re-use it instead of pointing out the obvious bad practice?


    You have troubles with your code mainly because it’s extremely hard to read! Your functions and variables have the same names which is bad and they are bad variable and function names in general!

    • Function names should have an ‘action word’ in them, a verb that shows what they do
    • Variable names should not contain numbers
    • Variable names should describe a container
    • Data types make for bad variable names ($string, $text, $int)

    Here is an example of how your class could look like, I named in ‘TextPuzzler’ because of @Matteo Riva ‘s comment.

    class TextPuzzler
    {
        protected $myText;
    
        public function setMyText($text)
        {
            $this->myText = $text;
        }
    
        public function getMyText()
        {
            return $this->myText;
        }
    
        public function printMyText()
        {
            echo $this->myText;
        }
    }
    
    $puzzler = new TextPuzzler();
    
    $text = "This is a random text";
    
    //this is how you set your text
    $puzzler->setMyText($text);
    
    //this is how you echo it via a special echo function, not really needed ...
    $puzzler->printMyText();
    
    //... because you can also use the getter and echo it like this
    echo $puzzler->getMyText();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling with Zend_Navigation all weekend, and now I have another problem, which
I have a menu item to which I add another item. Now I want
Say I have two models and one belongs to another. Now normaly you would
I have an CLLocation which is my userLocation, now in another class I have
I now have a file uploader that goes on like this This is the
In my view this is one of the strangest problem i have ever come
Now I have another problem with WCF server/client. I have a method: bool spr_wiersz(int
I have a table: Employee (employeeID) EmployeeRank (rankID, employeeID) Now I have another table
I have a string String mainString=///BUY/SELL///ORDERTIME///RT///QTY///BROKERAGE///NETRATE///AMOUNTRS///RATE///SCNM///; Now I have another strings String str1= RT;
i have about 60 fragments ListFragment , now i use each Listfragment with another

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.