Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Posts posted by justsomeguy

  1. Yes, only public members can be access from outside the class.  It's common to make things private and then have public getter and setter methods:

    class AccountInformation {
    
      private $fname;
    
      public function __construct($fname = '') {
        $this->fname = $fname; 
      }
    
      public function getFname() {
        return $this->fname;
      }
    
      public function setFname($fname) {
        $this->fname = $fname;
      }
    }
    
    $acct = new AccountInformation();
    $acct->setFname('Steve');
    echo $acct->getFname();

    The difference between protected and private is only with extended classes.  Neither of them can be accessed from outside of your class.   A protected member can be accessed from a class that extends your class, but a private member can only be accessed from inside your class.

    • Like 1
  2. The constructor always needs to be public.  If you want properties to be private you need to declare them as private first.  It's common to declare all of the properties before the methods.

    class AccountInformation {
    
      private $fname;
    
      private $connected = false; // you can initialize variables but only to scalar values, you can't initialize a property to another variable
    
      public function __construct($fname = '') {
    
        $this->fname = $fname; // you can only access a private property from inside this class
    
        $this->connect(); // you can only call a private method from inside this class
      }
    
      private function connect() {
    
      }
    
    }

    Have you always been in Finland?  My wife lived there for 5 years.

    • Like 1
  3. That means that it can't find the pear packages for whatever reason.

    You don't really need to install PHPMailer, just upload the files with your code and include them.  There's a button to download the zip package on the GitHub page, you need to upload the files inside the src directory, include the main PHPMailer class file in your code, and you can use it.  They have instructions for installing with composer and whatever else but that's just overcomplicated.

  4. It seems like a sort function would just change the order that the results appear.  If you want to limit what is returned you probably have to change the table specification to tell it to only return specific columns, but I'm not familiar with what you're using.  Hopefully it has documentation that you can use to check what your options are.

  5. It will listen on whatever port you tell it to, but you'll need to change the URLs in the browser also.  Skype is the most common application that listens on port 80 and blocks other applications from using it.

  6. You can download a package like XAMPP that has everything you might need.  You really only need Apache or another web server though if you're only serving static files.  Some versions of Windows have the IIS server included but you probably need to install it through the control panel first.

  7. You're mixing mysql and mysqli functions.  They don't work together.  You also immediately overwrite your insert query with a select query because you're using the same variable name.

  8. That's just a alternative way of defining a function in EcmaScript 6.  It's saying the function accepts 2 parameters, countDates and date, and then has the statements where it builds and then returns the array.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

    The empty object is the initial value to use for the accumulator for reduce.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce

    • Like 1
×
×
  • Create New...