OO PHP数组值丢失或丢失

I'm relatively new to OO PHP, and frankly PHP in general. I have a class that I assign the array values in the constructor. However, when I access the array later, it is telling me that the array is null. Any ideas how this is going out of scope?

class SentenceContentContainer {
    public $strSentence; //theSentence entered
    public $arrayOfWords = []; //words in the sentence
    private $num_words_in_sentence; 

    function __construct($strSentence)
    {
        $this->strSentence = $strSentence;
        $arrayOfWords = explode(" ", $strSentence); //get the array of words in the string
        $num_words_in_sentence = count($arrayOfWords); //count elements in the sentence
    }

    function sortHighestLetterRepeaterOfSentence()
    {
        usort($arrayOfWords, "compare"); //says parameter 1 is null
    }
...
}

This is accessed from:

<html>
<head><title>PHP Code</title></head>
<body>
<?php

     include "classes.php";

     //process the data input
     $post_string = implode("",$_POST); //change post array to string
     // instantiate 1 of 2 objects
     $sentenceCC = new SentenceContentContainer($post_string);

     call_user_method("sortHighestLetterRepeaterOfSentence",$sentenceCC);
     ?>
<form method="post" action="">
<input type="text" name="value">
<input type="submit">
</form>

</body>
</html>

When I tried adding this->arrayOfWords in the Sentence contructor, it said it was a syntax issue.

I wonder if the issue is that somehow it's running the call_user_method even though I haven't hit submit yet in the form, after entering the sentence? I wouldn't think it would have gotten there yet?

Added: When I invoke the script in the browser, before I hit submit in the form, is when I see the warning message.
Added Also: Maybe I need to check that $arrayOfWords is not null or something in sortHighestLetterRepeaterOfSentence? I tried adding a check for null, but It's saying Undefined variable arrayOfWords where I test it for != null. I was also considering isset, but it's unclear that this would fix it.

$arrayOfWords is a variable that only exists inside the __construct function.

$this->arrayOfWords is a private class variable that exists in any method of the class and has a different value per-instance.

P.S. Why are you using call_user_method? This function is deprecated (and I think removed in PHP 7). Just a quick note, if you saw that in a tutorial, you should consider a new tutorial as that one's gonna be outdated.

You can just do:

$sentenceCC->sortHighestLetterRepeaterOfSentence()

If you must, you can use call_user_func instead:

call_user_func([$sentenceCC, 'sortHighestLetterRepeaterOfSentence']);

Yes this code will execute even if form is not submitted.

I think your should check $_POST variable and allow to run your code only

if (count( $_POST ))