思维导图备注
PHP教程
首页 白天 夜间

extends

浏览 3 2026-06-03 21:23:43

❮ PHP 关键字

实例

从类继承:

<?php
class MyClass {
  public function hello() {
    echo "Hello World!";
  }
}

class AnotherClass extends MyClass {
}

$obj = new AnotherClass();
$obj->hello();
?>
亲自试一试 »

定义和用法

extends 关键字用于从另一个类派生一个类。 这称为继承。 派生类具有派生它的类的所有公共和受保护属性。


相关页面

在我们的PHP OOP - 继承教程中了解更多关于继承的信息。


❮ PHP 关键字
上一篇:
下一篇:
  • PHP 教程
  • PHP 教程
  • PHP 简介
  • PHP 下载安装和环境配置
  • PHP 语法
  • PHP 注释
  • PHP 变量
  • PHP Echo / Print
  • PHP 数据类型
  • PHP 字符串
  • PHP 数值
  • PHP Math
  • PHP 常量
  • PHP 运算符
  • PHP If...Else...Elseif
  • PHP Switch
  • PHP 循环
  • PHP 循环
  • While 循环
  • Do While 循环
  • For 循环
  • Foreach 循环
  • Break/Continue
  • PHP 函数
  • PHP 数组
  • PHP 数组
  • 索引数组
  • 关联数组
  • 多维数组
  • 数组排序
  • PHP 全局变量
  • Superglobals
  • $GLOBALS
  • $_SERVER
  • $_REQUEST
  • $_POST
  • $_GET
  • PHP 正则表达式
  • PHP 表单
  • PHP 表单处理
  • PHP 表单验证
  • PHP 表单验证必填字段
  • PHP 表单验证URL/E-mail
  • PHP 表单验证实例
  • PHP 高级教程
  • PHP 日期和时间
  • PHP Include
  • PHP 文件处理
  • PHP 文件打开/读取
  • PHP 文件创建/写入
  • PHP 文件上传
  • PHP Cookies
  • PHP Sessions
  • PHP Filters
  • PHP Filters Advanced
  • PHP 回调函数
  • PHP JSON
  • PHP 异常处理
  • PHP 面向对象
  • PHP 什么是 OOP
  • PHP 类和对象
  • PHP 构造函数
  • PHP 析构函数
  • PHP 访问修饰符
  • PHP 继承
  • PHP 类常量
  • PHP 抽象类
  • PHP 接口
  • PHP 特征
  • PHP 静态方法
  • PHP 静态属性
  • PHP 命名空间
  • PHP 可迭代对象
  • MySQL 数据库
  • MySQL Database
  • MySQL Connect
  • MySQL Create DB
  • MySQL Create Table
  • MySQL Insert Data
  • MySQL Get Last ID
  • MySQL Insert Multiple
  • MySQL Prepared
  • MySQL Select Data
  • MySQL Where
  • MySQL Order By
  • MySQL Delete Data
  • MySQL Update Data
  • MySQL Limit Data
  • PHP XML
  • PHP XML Parsers
  • PHP SimpleXML Parser
  • PHP SimpleXML - Get
  • PHP XML Expat
  • PHP XML DOM
  • PHP - AJAX
  • AJAX Intro
  • AJAX PHP
  • AJAX Database
  • AJAX XML
  • AJAX Live Search
  • AJAX Poll
  • PHP 实例
  • PHP 实例
  • PHP 编译器
  • PHP 测验
  • PHP 练习
  • PHP 参考手册
  • PHP 概述
  • PHP Array
  • array()
  • array_change_key_case()
  • array_chunk()
  • array_column()
  • array_combine()
  • array_count_values()
  • array_diff()
  • array_diff_assoc()
  • array_diff_key()
  • array_diff_uassoc()
  • array_diff_ukey()
  • array_fill()
  • array_fill_keys()
  • array_filter()
  • array_flip()
  • array_intersect()
  • array_intersect_assoc()
  • array_intersect_key()
  • array_intersect_uassoc()
  • array_intersect_ukey()
  • array_key_exists()
  • array_keys()
  • array_map()
  • array_merge()
  • array_merge_recursive()
  • array_multisort()
  • array_pad()
  • array_pop()
  • array_product()
  • array_push()
  • array_rand()
  • array_reduce()
  • array_replace()
  • array_replace_recursive()
  • array_reverse()
  • array_search()
  • array_shift()
  • array_slice()
  • array_splice()
  • array_sum()
  • array_udiff()
  • array_udiff_assoc()
  • array_udiff_uassoc()
  • array_uintersect()
  • array_uintersect_assoc()
  • array_uintersect_uassoc()
  • array_unique()
  • array_unshift()
  • array_values()
  • array_walk()
  • array_walk_recursive()
  • arsort()
  • asort()
  • compact()
  • count()
  • current()
  • each()
  • end()
  • extract()
  • in_array()
  • key()
  • krsort()
  • ksort()
  • list()
  • natcasesort()
  • natsort()
  • next()
  • pos()
  • prev()
  • range()
  • reset()
  • rsort()
  • shuffle()
  • sizeof()
  • sort()
  • uasort()
  • uksort()
  • usort()
  • PHP Calendar
  • cal_days_in_month()
  • cal_from_jd()
  • cal_info()
  • cal_to_jd()
  • easter_date()
  • easter_days()
  • frenchtojd()
  • gregoriantojd()
  • jddayofweek()
  • jdmonthname()
  • jdtofrench()
  • jdtogregorian()
  • jdtojewish()
  • jdtojulian()
  • jdtounix()
  • jewishtojd()
  • juliantojd()
  • unixtojd()
  • PHP Date
  • checkdate()
  • date_add()
  • date_create_from_format()
  • date_create()
  • date_date_set()
  • date_default_timezone_get()
  • date_default_timezone_set()
  • date_diff()
  • date_format()
  • date_get_last_errors()
  • date_interval_create_from_date_string()
  • date_interval_format()
  • date_isodate_set()
  • date_modify()
  • date_offset_get()
  • date_parse_from_format()
  • date_parse()
  • date_sub()
  • date_sun_info()
  • date_sunrise()
  • date_sunset()
  • date_time_set()
  • date_timestamp_get()
  • date_timestamp_set()
  • date_timezone_get()
  • date_timezone_set()
  • date()
  • getdate()
  • gettimeofday()
  • gmdate()
  • gmmktime()
  • gmstrftimee()
  • idate()
  • localtime()
  • microtime()
  • mktime()
  • strftime()
  • strptime()
  • strtotime()
  • time()
  • timezone_abbreviations_list()
  • timezone_identifiers_list()
  • timezone_location_get()
  • timezone_name_from_abbr()
  • timezone_name_get()
  • timezone_offset_get()
  • timezone_open()
  • timezone_transitions_get()
  • timezone_version_get()
  • PHP Directory
  • chdir()
  • chroot()
  • closedir()
  • dir()
  • getcwd()
  • opendir()
  • readdir()
  • rewinddir()
  • scandir()
  • PHP Error
  • debug_backtrace()
  • debug_print_backtrace()
  • error_get_last()
  • error_log()
  • error_reporting()
  • restore_error_handler()
  • restore_exception_handler()
  • set_error_handler()
  • set_exception_handler()
  • trigger_error()
  • PHP Exception
  • Exception()
  • getCode()
  • getFile()
  • getMessage()
  • getLine()
  • getPrevious()
  • getTrace()
  • getTraceAsString()
  • PHP Filesystem
  • basename()
  • chgrp()
  • chmod()
  • chown()
  • clearstatcache()
  • copy()
  • delete()
  • dirname()
  • disk_free_space()
  • disk_total_space()
  • diskfreespace()
  • fclose()
  • feof()
  • fflush()
  • fgetc()
  • fgetcsv()
  • fgets()
  • fgetss()
  • file()
  • file_exists()
  • file_get_contents()
  • file_put_contents()
  • fileatime()
  • filectime()
  • filegroup()
  • fileinode()
  • filemtime()
  • fileowner()
  • fileperms()
  • filesize()
  • filetype()
  • flock()
  • fnmatch()
  • fopen()
  • fpassthru()
  • fputcsv()
  • fputs()
  • fread()
  • fscanf()
  • fseek()
  • fstat()
  • ftell()
  • ftruncate()
  • fwrite()
  • glob()
  • is_dir()
  • is_executable()
  • is_file()
  • is_link()
  • is_readable()
  • is_uploaded_file()
  • is_writable()
  • is_writeable()
  • lchgrp()
  • lchown()
  • link()
  • linkinfo()
  • lstat()
  • mkdir()
  • move_uploaded_file()
  • parse_ini_file()
  • parse_ini_string()
  • pathinfo()
  • pclose()
  • popen()
  • readfile()
  • readlink()
  • realpath()
  • realpath_cache_get()
  • realpath_cache_size()
  • rename()
  • rewind()
  • rmdir()
  • set_file_buffer()
  • stat()
  • symlink()
  • tempnam()
  • tmpfile()
  • touch()
  • umask()
  • unlink()
  • PHP Filter
  • filter_has_var()
  • filter_id()
  • filter_input()
  • filter_input_array()
  • filter_list()
  • filter_var()
  • filter_var_array()
  • PHP FTP
  • ftp_alloc()
  • ftp_cdup()
  • ftp_chdir()
  • ftp_chmod()
  • ftp_close()
  • ftp_connect()
  • ftp_delete()
  • ftp_exec()
  • ftp_fget()
  • ftp_fput()
  • ftp_get()
  • ftp_get_option()
  • ftp_login()
  • ftp_mdtm()
  • ftp_mkdir()
  • ftp_mlsd()
  • ftp_nb_continue()
  • ftp_nb_fget()
  • ftp_nb_fput()
  • ftp_nb_get()
  • ftp_nb_put()
  • ftp_nlist()
  • ftp_pasv()
  • ftp_put()
  • ftp_pwd()
  • ftp_quit()
  • ftp_raw()
  • ftp_rawlist()
  • ftp_rename()
  • ftp_rmdir()
  • ftp_set_option()
  • ftp_site()
  • ftp_size()
  • ftp_ssl_connect()
  • ftp_systype()
  • PHP JSON
  • json_decode()
  • json_encode()
  • PHP Keywords
  • abstract
  • and
  • as
  • break
  • callable
  • case
  • catch
  • class
  • clone
  • const
  • continue
  • declare
  • default
  • do
  • echo
  • else
  • elseif
  • empty
  • enddeclare
  • endfor
  • endforeach
  • endif
  • endswitch
  • extends
  • final
  • finally
  • fn
  • for
  • foreach
  • function
  • global
  • if
  • implements
  • include
  • include_once
  • instanceof
  • insteadof
  • interface
  • isset
  • list
  • namespace
  • new
  • or
  • print
  • private
  • protected
  • public
  • require
  • require_once
  • return
  • static
  • switch
  • throw
  • trait
  • try
  • use
  • var
  • while
  • xor
  • yield
  • yield from
  • PHP Libxml
  • libxml_clear_errors()
  • libxml_disable_entity_loader()
  • libxml_get_errors()
  • libxml_get_last_error()
  • libxml_set_external_entity_loader()
  • libxml_set_streams_context()
  • libxml_use_internal_errors()
  • PHP Mail
  • ezmlm_hash()
  • mail()
  • PHP Math
  • abs()
  • acos()
  • acosh()
  • asin()
  • asinh()
  • atan()
  • atan2()
  • atanh()
  • base_convert()
  • bindec()
  • ceil()
  • cos()
  • cosh()
  • decbin()
  • dechex()
  • decoct()
  • deg2rad()
  • exp()
  • expm1()
  • floor()
  • fmod()
  • getrandmax()
  • hexdec()
  • hypot()
  • intdiv()
  • is_finite()
  • is_infinite()
  • is_nan()
  • lcg_value()
  • log()
  • log10()
  • log1p()
  • max()
  • min()
  • mt_getrandmax()
  • mt_rand()
  • mt_srand()
  • octdec()
  • pi()
  • pow()
  • rad2deg()
  • rand()
  • round()
  • sin()
  • sinh()
  • sqrt()
  • srand()
  • tan()
  • tanh()
  • PHP Misc
  • connection_aborted()
  • connection_status()
  • connection_timeout()
  • constant()
  • define()
  • defined()
  • die()
  • eval()
  • exit()
  • get_browser()
  • __halt_compiler()
  • highlight_file()
  • highlight_string()
  • hrtime()
  • ignore_user_abort()
  • pack()
  • php_strip_whitespace()
  • show_source()
  • sleep()
  • sys_getloadavg()
  • time_nanosleep()
  • time_sleep_until()
  • uniqid()
  • unpack()
  • usleep()
  • PHP MySQLi
  • affected_rows
  • autocommit
  • change_user
  • character_set_name
  • close
  • commit
  • connect
  • connect_errno
  • connect_error
  • data_seek
  • debug
  • dump_debug_info
  • errno
  • error
  • error_list
  • fetch_all
  • fetch_array
  • fetch_assoc
  • fetch_field
  • fetch_field_direct
  • fetch_fields
  • fetch_lengths
  • fetch_object
  • fetch_row
  • field_count
  • field_seek
  • get_charset
  • get_client_info
  • get_client_stats
  • get_client_version
  • get_connection_stats
  • get_host_info
  • get_proto_info
  • get_server_info
  • get_server_version
  • info
  • init
  • insert_id
  • kill
  • more_results
  • multi_query
  • next_result
  • options
  • ping
  • poll
  • prepare
  • query
  • real_connect
  • real_escape_string
  • real_query
  • reap_async_query
  • refresh
  • rollback
  • select_db
  • set_charset
  • set_local_infile_handler
  • sqlstate
  • ssl_set
  • stat
  • stmt_init
  • thread_id
  • thread_safe
  • use_result
  • warning_count
  • PHP Network
  • checkdnsrr()
  • closelog()
  • dns_check_record()
  • dns_get_mx()
  • dns_get_record()
  • fsockopen()
  • gethostbyaddr()
  • gethostbyname()
  • gethostbynamel()
  • gethostname()
  • getmxrr()
  • getprotobyname()
  • getprotobynumber()
  • getservbyname()
  • getservbyport()
  • header_register_callback()
  • header_remove()
  • header()
  • headers_list()
  • headers_sent()
  • http_response_code()
  • inet_ntop()
  • inet_pton()
  • ip2long()
  • long2ip()
  • openlog()
  • pfsockopen()
  • setcookie()
  • setrawcookie()
  • socket_get_status()
  • socket_set_blocking()
  • socket_set_timeout()
  • syslog()
  • PHP Output Control
  • flush()
  • ob_clean()
  • ob_end_clean()
  • ob_end_flush()
  • ob_flush()
  • ob_get_clean()
  • ob_get_contents()
  • ob_get_flush()
  • ob_get_length()
  • ob_get_level()
  • ob_gzhandler()
  • ob_implicit_flush()
  • ob_list_handlers()
  • ob_start()
  • output_add_rewrite_var()
  • output_reset_rewrite_vars()
  • PHP RegEx
  • preg_filter()
  • preg_grep()
  • preg_last_error()
  • preg_match()
  • preg_match_all()
  • preg_replace
  • preg_replace_callback
  • preg_replace_callback_array
  • preg_split
  • preg_quote
  • PHP SimpleXML
  • __construct()
  • __tostring()
  • addAttribute()
  • addChild()
  • asXML()
  • attributes()
  • children()
  • count()
  • getDocNamespaces()
  • getName()
  • getNamespaces()
  • registerXPathNamespace()
  • saveXML()
  • simplexml_import_dom()
  • simplexml_load_file()
  • simplexml_load_string()
  • xpath()
  • current()
  • getchildren()
  • haschildren()
  • key()
  • next()
  • rewind()
  • valid()
  • PHP Stream
  • PHP String
  • addcslashes()
  • addslashes()
  • bin2hex()
  • chop()
  • chr()
  • chunk_split()
  • convert_cyr_string()
  • convert_uudecode()
  • convert_uuencode()
  • count_chars()
  • crc32()
  • crypt()
  • echo()
  • explode()
  • fprint()
  • get_html_translation_table()
  • hebrev()
  • hebrevc()
  • hex2bin()
  • html_entity_decode()
  • htmlentities()
  • htmlspecialchars_decode()
  • htmlspecialchars()
  • implode()
  • join()
  • lcfirst()
  • levenshtein()
  • localeconv()
  • ltrim()
  • md5()
  • md5_file()
  • metaphone()
  • money_format()
  • nl_langinfo()
  • nl2br()
  • number_format()
  • ord()
  • parse_str()
  • print()
  • printf()
  • quoted_printable_decode()
  • quoted_printable_encode()
  • quotemeta()
  • rtrim()
  • setlocale()
  • sha1()
  • sha1_file()
  • similar_text()
  • soundex()
  • sprintf()
  • sscanf()
  • str_getcsv()
  • str_ireplace()
  • str_pad()
  • str_repeat()
  • str_replace()
  • str_rot13()
  • str_shuffle()
  • str_split()
  • str_word_count()
  • strcasecmp()
  • strchr()
  • strcmp()
  • strcoll()
  • strcspn()
  • strip_tags()
  • stripcslashes()
  • stripslashes()
  • stripos()
  • stristr()
  • strlen()
  • strnatcasecmp()
  • strnatcmp()
  • strncasecmp()
  • strncmp()
  • strpbrk()
  • strpos()
  • strrchr()
  • strrev()
  • strripos()
  • strrpos()
  • strspn()
  • strstr()
  • strtok()
  • strtolower()
  • strtoupper()
  • strtr()
  • substr()
  • substr_compare()
  • substr_count()
  • substr_replace()
  • trim()
  • ucfirst()
  • ucwords()
  • vfprintf()
  • vprintf()
  • vsprintf()
  • wordwrap()
  • PHP Variable Handling
  • boolval()
  • debug_zval_dump()
  • doubleval()
  • is_countable()
  • empty()
  • floatval()
  • get_defined_vars()
  • get_resource_type()
  • gettype()
  • intval()
  • is_array()
  • is_bool()
  • is_callable()
  • is_double()
  • is_float()
  • is_int()
  • is_integer()
  • is_iterable()
  • is_long()
  • is_null()
  • is_numeric()
  • is_object()
  • is_real()
  • is_resource()
  • is_scalar()
  • is_string()
  • isset()
  • print_r()
  • serialize()
  • settype()
  • strval()
  • unserialize()
  • unset()
  • var_dump()
  • var_export()
  • PHP XML Parser
  • utf8_decode()
  • utf8_encode()
  • xml_error_string()
  • xml_get_current_byte_index()
  • xml_get_current_column_number()
  • xml_get_current_line_number()
  • xml_get_error_code()
  • xml_parse()
  • xml_parse_into_struct()
  • xml_parser_create_ns()
  • xml_parser_create()
  • xml_parser_free()
  • xml_parser_get_option()
  • xml_parser_set_option()
  • xml_set_character_data_handler()
  • xml_set_default_handler()
  • xml_set_element_handler()
  • xml_set_end_namespace_decl_handler()
  • xml_set_external_entity_ref_handler()
  • xml_set_notation_decl_handler()
  • xml_set_object()
  • xml_set_processing_instruction_handler()
  • xml_set_start_namespace_decl_handler()
  • xml_set_unparsed_entity_decl_handler()
  • PHP Zip
  • zip_close()
  • zip_entry_close()
  • zip_entry_compressedsize()
  • zip_entry_compressionmethod()
  • zip_entry_filesize()
  • zip_entry_name()
  • zip_entry_open()
  • zip_entry_read()
  • zip_open()
  • zip_read()
  • PHP Timezones
暂无相关搜索结果!

    文章二维码

    手机扫一扫,轻松掌上读

    文档下载

    • 普通下载
    • 下载码下载(免登录无限下载)
    你与大神的距离,只差一个APP
    APP下载
    请下载您需要的格式的文档,随时随地,享受汲取知识的乐趣!
    PDF文档 EPUB文档 MOBI文档
    温馨提示 每天每在网站阅读学习一分钟时长可下载一本电子书,每天连续签到可增加阅读时长
    下载码方式下载:免费、免登录、无限制。 免费获取下载码

    微信小程序阅读

    BookChat 微信小程序阅读
    您与他人的薪资差距,只差一个随时随地学习的小程序

    书签列表

      阅读记录

      阅读进度: 0.00% ( 0/0 ) 重置阅读进度

        欢迎使用AI助手 AI助手
        全屏 缩小 隐藏 清空