Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- javascript
- MIPS
- Linux
- Class
- system
- DS
- data structure
- DATAPATH
- html
- instruction
- web
- control
- mysql
- Pipelining
- github
- MacOS
- function
- CSS
- for
- Java
- while
- Algorithm
- architecture
- computer
- DoM
- react
- python
- DB
- XML
- php
Archives
- Today
- Total
YYYEJI
[PHP] Class 만들기 본문
728x90
Class를 만들고 Constructor의 변수를 초기화 시켜줍니다.
<!EOCTYPE html>
<body>
<h1>My first PHP page</h1>
<?php
class Fruit {
function Fruit() {
$this->berry = "Strawberry";
}
}
$f = new Fruit();
echo $f->berry;
?>
</body>
$f라는 새로운 객체(object)를 선언해주고, 객체의 변수를 출력하면 Strawberry가 출력됩니다.
◡̈
'HTML(or XML) & CSS & JavaScript' 카테고리의 다른 글
[PHP] PHP의 1차원 Array (0) | 2022.12.12 |
---|---|
[PHP] 함수 만들기 (0) | 2022.12.12 |
[PHP] PHP 변수 type 확인 (0) | 2022.12.12 |
[PHP] 문자열 합치기 (String concatenation) (0) | 2022.12.12 |
[PHP] PHP 변수의 Scope (0) | 2022.12.12 |