PHP Specifies the parameter class

Source: Internet
Author: User
PHP Specifies parameter types
Public Function Execute (pwthreaddatasource $ds) {
$this->_ds = $ds;


It is said that PHP does not specify the type when declaring the variable, then why does this parameter indicate the Pwthreaddatasource type? And this is an abstract class, isn't an abstract class not able to declare an object? Do not understand, it is polymorphic?
Abstract class Pwthreaddatasource {

Protected $urlArgs = Array ();

/**
* Get post statistics
*
* @return int
*/
Abstract public Function gettotal ();

/**
* Get posts
*
* @param int $limit Get entry
* @param int $offset post start offset
* @return Array
*/
Abstract public Function GetData ($limit, $offset);


------Solution--------------------
Execute (pwthreaddatasource $ds)
This $ds is a formal parameter that is only intended to be used by the caller to pass in an object of the Pwthreaddatasource class or its subclasses for the code within the function to invoke.
This is also to coordinate the coding, at least I do not have to look at the comments or code, I know what parameters to pass in.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.