<?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.
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: [email protected]
How to implement parameterized configuration in class definition without using metaclass=
20 Apr 2026
By overriding the __init_subclass__ method of the base class, parameters (such as exclude=, custom=) can be passed directly during inheritance, completely avoiding the explicit declaration of metaclass=, which is both concise and highly compatible, and avoids the risk of multi-layer metaclass conflicts.
How to enable Pico.css on demand in a project without polluting styles globally
09 Feb 2026
Pico.css has provided the pico.conditional.min.css version since v2, which only takes effect on elements with class="pico" added, completely solving the problem of style conflicts with other UI libraries.
How to define a class and object in PHP? (OOP Tutorial)
06 Jan 2026
You need to use the class keyword to define a class, and use newClassName() to create an object; a class is a blueprint, including attributes and methods, and is initialized through the constructor __construct. $this is used to access instance members, and attributes must be declared public and have other visibility.
What is the difference between mysql full database recovery and single database recovery_mysql operation method instructions
09 Feb 2026
Full database recovery is to directly import the SQL file generated by mysqldump--all-databases, covering all libraries (including system libraries). The risk is high, but it is suitable for the entire instance crash; you must check the CREATEDATABASE statement, target library list and character set, SQL mode, permission library synchronization and other details.
How to dynamically add class attributes to specific HTML tags in PHP
28 Mar 2026
This article explains in detail how to use PHP to safely and accurately inject class="dropdown-toggle" into specified tags (such as links containing the text "Additional") to avoid accidentally changing other tags, and compare the applicable boundaries of DOM operations and regular schemes.
How to define a class in Java_Basic definition analysis of Java classes
08 Feb 2026
The core of Java class definition is the rational use of access modifiers, constructors and member design: public must be explicitly declared (otherwise it will not be visible across packages), a file must have at most one public class and the file name must match; the constructor must explicitly provide a parameter-free version to prevent reflection or deserialization failure; members should be private by default and equipped with getters/setters, static fields must be thread-safe, and final fields must be assigned in declarations, constructors or initialization blocks.
Popular tool
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
PHP library for dependency injection containers
PHP library for dependency injection containers
Small PHP library for optimizing images
Small PHP library for optimizing images




