-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasics.php
More file actions
53 lines (46 loc) · 1.53 KB
/
Copy pathBasics.php
File metadata and controls
53 lines (46 loc) · 1.53 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace Jobtrek\ExPhp;
class Basics
{
/**
* Php is a bit particular from other languages, important things :
* - PHP files always start with `<?php`
* - All php variables are prefixed with `$`, there is no `var` ou `let` keyword
* - Methods on objects are accessed with `->` not `.` like in other languages
* - If types are specified, they goes before the variable name, without `:` unlike TypeScript or Rust types
*
* Modern PHP (version 8+) are very similar to Java, you have a type system, class, interfaces.
* But php is still a dynamically typed language, so if you don't provide types, you have no guarantees
* to get what you want, like in JavaScript.
*
* Complete the function to add the two provided int numbers
*/
public static function add(int $number1, int $number2): int
{
}
/**
* Return the length of a string
*/
public static function length(string $str): int
{
}
/**
* Return true if the string have more than 10 characters
*/
public static function condition(string $str): bool
{
}
/**
* Concatenate two strings
*/
public static function concatenate(string $str1, string $str2): string
{
}
/**
* Analyse the string, and cut to the number of words requested. If the number of
* words requested is bigger than the string word count, duplicate the last word.
*/
public static function getWordsToCount(string $str, int $wordsCountToRemain): string
{
}
}