Forum > Networking and Web Programming

[SOLVED] Regarding PHP

(1/3) > >>

egsuh:
May I think that PHP is similar to the ASP (Active Server Page) or javascript? With "similar", I mean ASP or javascript is written in a section within HTML, blocked with <%.. %> or <script>... </script>.  I found that PHP is within <?php ... ?>.

Just interested in this, in order to compare PHP and FreePascal in webserver.

abunakov:
PHP is similar to ASP in a way. Although I'd rather say that ASP is similar to PHP since PHP was first.
Both use similar constructs to denote code snippets inside an HTML page.

There is a big difference between PHP/ASP and JavaScript though.

Scripts within <script> tags are transmitted from the server to the browser and executed by the browser runtime (i.e. on the client).

In contrast, PHP scripts are executed on the server by PHP interpreter. PHP replaces those <?php ...> snippets with HTML markup. So the the browser will never see any of <?php ...> tags.

ASP work in a similar way.

There is also Node.js. It's a JavaScript runtime which like PHP also runs on the server.

But still it's important to remember which parts of code run where. PHP/ASP/Node.js run on the server. JavaScript enclosed in <script> tags runs in the browser.

Read more about PHP here:
https://www.php.net/manual/en/intro-whatis.php

egsuh:
@abunakov

Thank you for your reply. I know that PHP and ASP are server-side scripts and javascript is client-side script.
Just wanted to check that PHP codes are immersed into HTML pages (like ASP, node.js, or javascript codes). With this much information, I can imagine how it works (whether right or wrong :D) enough to compare with Free Pascal's web working. Thanks again.

Thaddy:

--- Quote from: egsuh on June 29, 2023, 07:49:21 am ---I can imagine how it works (whether right or wrong :D) enough to compare with Free Pascal's web working. Thanks again.

--- End quote ---
That means you still do not fully understand it:
1. FreePascal has bindings for all the serverside scripting either PHP, JavaScript, Java (sec) or others.
2. FreePascal can also be natively used serverside, which can be often faster.
3. FreePascal has even Pas2JS, which enables JavaScript programming using Object Pascal code.
4. FreePascal even supports compiled webassembly code through a native cross compiler on multiple platforms.

So whatever you prefer is already provided in standard FreePascal libraries and (cross) compilers. It is just up to you what you find the better option for your task at hand.
I do not know of any compiler that supports all the above options.

egsuh:
@Thaddy,

I've written several web server programs with Free Pascal, and nothing else.  I'm checking how to use others like PHP, Node.js, etc. to explain the characteristics of my approach.

Navigation

[0] Message Index

[#] Next page

Go to full version