-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,239 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
org.eclipse.tm4e.language_pack/syntaxes/php/php.example.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
// Variables and Data Types | ||
$name = "John"; | ||
$age = 30; | ||
$isStudent = false; | ||
$grades = [85, 90, 78]; | ||
|
||
// Control Structures | ||
if ($age >= 18) { | ||
echo "Welcome, $name! You are eligible."; | ||
} else { | ||
echo "Sorry, $name. You are not eligible."; | ||
} | ||
|
||
// Loops | ||
for ($i = 0; $i < count($grades); $i++) { | ||
echo "Grade $i: {$grades[$i]}"; | ||
} | ||
|
||
// Functions | ||
function greet($name) { | ||
return "Hello, $name!"; | ||
} | ||
|
||
echo greet($name); | ||
|
||
// Arrays | ||
$colors = ["red", "green", "blue"]; | ||
$associativeArray = [ | ||
"name" => "Jane", | ||
"age" => 25, | ||
"isStudent" => true | ||
]; | ||
|
||
// Classes and Objects | ||
class Person { | ||
public $name; | ||
public $age; | ||
|
||
public function __construct($name, $age) { | ||
$this->name = $name; | ||
$this->age = $age; | ||
} | ||
|
||
public function greet() { | ||
echo "Hello, my name is $this->name."; | ||
} | ||
} | ||
|
||
$person = new Person("Alice", 22); | ||
$person->greet(); | ||
|
||
// Traits | ||
trait Logging { | ||
public function log($message) { | ||
echo "Logging: $message"; | ||
} | ||
} | ||
|
||
// Namespaces | ||
namespace MyApp; | ||
|
||
// Error Handling | ||
try { | ||
// Code that might throw an exception | ||
throw new Exception("Something went wrong!"); | ||
} catch (Exception $e) { | ||
echo "Caught exception: " . $e->getMessage(); | ||
} | ||
|
||
// File Handling | ||
$fileContent = file_get_contents("example.txt"); | ||
file_put_contents("output.txt", $fileContent); | ||
|
||
// Regular Expressions | ||
$pattern = "/\d{2}-\d{2}-\d{4}/"; | ||
$dateString = "12-31-2022"; | ||
|
||
if (preg_match($pattern, $dateString)) { | ||
echo "Valid date format."; | ||
} else { | ||
echo "Invalid date format."; | ||
} | ||
?> |
81 changes: 81 additions & 0 deletions
81
org.eclipse.tm4e.language_pack/syntaxes/php/php.language-configuration.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{ | ||
"comments": { | ||
"lineComment": "//", // "#" | ||
"blockComment": [ "/*", "*/" ] | ||
}, | ||
"brackets": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"] | ||
], | ||
"autoClosingPairs": [ | ||
{ "open": "{", "close": "}", "notIn": ["string"] }, | ||
{ "open": "[", "close": "]", "notIn": ["string"] }, | ||
{ "open": "(", "close": ")", "notIn": ["string"] }, | ||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }, | ||
{ "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, | ||
{ "open": "/**", "close": " */", "notIn": ["string"] } | ||
], | ||
"surroundingPairs": [ | ||
["{", "}"], | ||
["[", "]"], | ||
["(", ")"], | ||
["'", "'"], | ||
["\"", "\""], | ||
["`", "`"] | ||
], | ||
"indentationRules": { | ||
"increaseIndentPattern": "({(?!.*}).*|\\(|\\[|((else(\\s)?)?if|else|for(each)?|while|switch|case).*:)\\s*((/[/*].*|)?$|\\?>)", | ||
"decreaseIndentPattern": "^(.*\\*\\/)?\\s*((\\})|(\\)+[;,])|(\\]\\)*[;,])|\\b(else:)|\\b((end(if|for(each)?|while|switch));))" | ||
}, | ||
"folding": { | ||
"markers": { | ||
"start": "^\\s*(#|\/\/)region\\b", | ||
"end": "^\\s*(#|\/\/)endregion\\b" | ||
} | ||
}, | ||
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\-\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)", | ||
"onEnterRules": [ | ||
{ | ||
// e.g. /** | */ | ||
"beforeText": "^\\s*\\/\\*\\*(?!\\/)([^\\*]|\\*(?!\\/))*$", | ||
"afterText": "^\\s*\\*\\/$", | ||
"action": { | ||
"indent": "indentOutdent", | ||
"appendText": " * " | ||
} | ||
}, | ||
{ | ||
// e.g. /** ...| | ||
"beforeText": "^\\s*\\/\\*\\*(?!\\/)([^\\*]|\\*(?!\\/))*$", | ||
"action": { | ||
"indent": "none", | ||
"appendText": " * " | ||
} | ||
}, | ||
{ | ||
// e.g. * ...| | ||
"beforeText": "^(\\t|(\\ \\ ))*\\ \\*(\\ ([^\\*]|\\*(?!\\/))*)?$", | ||
"action": { | ||
"indent": "none", | ||
"appendText": "* ", | ||
}, | ||
}, | ||
{ | ||
// e.g. */| | ||
"beforeText": "^(\\t|(\\ \\ ))*\\ \\*\\/\\s*$", | ||
"action": { | ||
"indent": "none", | ||
"removeText": 1 | ||
}, | ||
}, | ||
{ | ||
// e.g. *-----*/| | ||
"beforeText": "^(\\t|(\\ \\ ))*\\ \\*[^/]*\\*\\/\\s*$", | ||
"action": { | ||
"indent": "none", | ||
"removeText": 1 | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.