search
php definition class
<?php
class Student
{
  var $str_Name;
  var $str_Sex;
  var $int_Id;
  var $int_English;
  var $int_maths;
  function  Input ( $Name, $Sex, $Id, $English, $Maths)
  {
    $this->str_Name=$Name;
    $this->str_Sex =$Sex;
    $this->int_Id =$Id;
    $this->int_English=$English;
    $this->int_Maths=$Maths;
  }
  function ShowInfo()
  {
      echo ("姓名:$this->str_Name<br>
  ");
  echo ("性别:$this->str_Sex <br>
  ");
  echo ("学号:$this->int_Id <br>
  ");
  echo ("英语成绩:$this->int_English <br>
  ");
  echo ("数学成绩:$this->int_Maths <br>
  ");
  }
}
  $Wing = new Student;
  $Wing->Input ("Wing","男",33,95,87);
  $Paladin = new Student;  
  $Paladin->Input ("paladin","女",38,58,59.5);  
  $Wing->ShowInfo();
  $Paladin->ShowInfo();
?>

Defines the human class, including name, gender, student number, English score, math score, etc.

Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

What are some very useful class libraries or tool libraries for PHP?What are some very useful class libraries or tool libraries for PHP?

06Jul2016

What are some very useful class libraries or tool libraries for PHP?

How Do I Link Static Libraries That Depend on Other Static Libraries?How Do I Link Static Libraries That Depend on Other Static Libraries?

13Dec2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

Can I Include Code Directly Inside a PHP Class Definition?Can I Include Code Directly Inside a PHP Class Definition?

19Nov2024

Can I Include Code into a PHP Class?The Answer:No, you cannot directly include code within the body of a class in PHP. Inclusions must be...

Can I Include External Files Directly Inside a PHP Class Definition?Can I Include External Files Directly Inside a PHP Class Definition?

26Nov2024

Can I Include Code into a PHP Class?Question: Is it possible to include an external file containing method definitions into a PHP class?Answer:...

How Can I Include External Methods into My PHP Class Definition?How Can I Include External Methods into My PHP Class Definition?

19Nov2024

Including Code in PHP Classes: Exploring Feasibility and AlternativesProblem:You seek to include methods from a separate file into your PHP class...

Why Do PHP Developers Use Leading Underscores in Class Methods?Why Do PHP Developers Use Leading Underscores in Class Methods?

11Nov2024

Hidden Truths: The Leading Underscore in PHP Class MethodsWhen browsing PHP libraries, one might stumble upon class methods prefixed with a...

See all articles