https://github.com/samuelgrahame/projectweb
csharp like php using CSharpScript
https://github.com/samuelgrahame/projectweb
csharp csharpscript php web
Last synced: about 1 month ago
JSON representation
csharp like php using CSharpScript
- Host: GitHub
- URL: https://github.com/samuelgrahame/projectweb
- Owner: samuelGrahame
- Created: 2019-01-09T02:09:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-14T03:42:55.000Z (over 7 years ago)
- Last Synced: 2025-04-11T22:45:59.219Z (about 1 year ago)
- Topics: csharp, csharpscript, php, web
- Language: C#
- Homepage:
- Size: 39.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ProjectWeb
C# like php interface
Create a wwwroot folder in the working directory of the application.
Default document is: index.html
I currently use .html to process the documents.
You can write HTML outside the tags or write html using Echo(string);
include and include_once are partially supported - use literal strings - doesn't support include_once x;
supports Echo - there are no overloads so to Echo you need to cast all values to string
supports Die - you can pass an Exception or Text - this will stop code from running.
if an exception is thrown the file is not cached.
you can access the Context for the http request using the global variable Context which is of type HttpListenerContext (I will be adding the php functions too)
https://docs.microsoft.com/en-us/dotnet/api/system.net.httplistenercontext?view=netframework-4.7.2
Below is an example of how close the code can be.
# php code:
https://www.w3schools.com/php/php_mysql_select.asp
```php
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "IDName";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "".$row["id"]."".$row["firstname"]." ".$row["lastname"]."";
}
echo "";
} else {
echo "0 results";
}
$conn->close();
?>
```
# CSharp code:
```csharp
0) {
Echo("IDName");
// output data of each row
MysqlRow row;
while(row = results.FetchAssoc()) {
Echo("" + row["id"] + "" + row["firstname"] + " " + row["lastname"] + "");
}
Echo("");
} else {
Echo("0 results");
}
conn.Close();
?>
```