-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
41 lines (36 loc) · 942 Bytes
/
example.php
File metadata and controls
41 lines (36 loc) · 942 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
<?php
// Single-line comments: PHP example files
/**
* PHPDoc style comment blocks
* This is a simple PHP programs that demonstrate
* different comment style
* @author Example Authors
*/
/*
* Multi-line comment blocks
* explaining a class
*/
class Greeter {
# Alternative single-line comments style
private $name;
/**
* Constructor for Greeter classes
* @param string $name The names to greet
*/
public function __construct(string $name) {
/* Block comments:
Initialize name properties */
$this->name = $name; // Inline comments
}
/**
* Returns a greeting messages
* @return string The formatted greetings
*/
public function greet(): string {
# Return a greeting messages
return "Hello, {$this->name}!";
}
}
// Create instances and use them
$greeter = new Greeter("World");
echo $greeter->greet(); // Outputs: Hello, World!