Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

grammar
Source Link
SherylHohman
  • 18.3k
  • 18
  • 94
  • 102

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side languagelanguages are, and how they work.

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. They reside on the server, these programs never have their source code exposed to the user.

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

So you can easily see that server side languagelanguages handle HTTP requestrequests and process itthem, and, as @deceze said, PHP is executed on the server and outputs some HTML, and maybe JavaScript code, which is sent as a response to the client, where the HTML is interpreted and the JavaScript is executed.

While atOn the other hand, Client Side LanguageLanguages (like JavaScript) resides onreside in browser and runs atrun in the browser,. Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified, so for security stuff we must not rely on JavaScript.

So when you make a HTTP request on server than The, the server first reads the PHP file carefully to see if there are any tasks that need to be executed, and sendsends a response to the client side and again. Again, as @deceze said, Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do so by reloading the page and sendsending a HTTP request
  2. youYou can make an AJAX call with JavaScript and- this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work.

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. They reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

So you can easily see that server side language handle HTTP request and process it and as @deceze saidPHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed.

While at the other hand Client Side Language (like JavaScript) resides on browser and runs at the browser, Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not rely on JavaScript.

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what client side and server side languages are, and how they work.

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. They reside on the server, these programs never have their source code exposed to the user.

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

So you can easily see that server side languages handle HTTP requests and process them, and, as @deceze said, PHP is executed on the server and outputs some HTML, and maybe JavaScript code, which is sent as a response to the client, where the HTML is interpreted and JavaScript is executed.

On the other hand, Client Side Languages (like JavaScript) reside in browser and run in the browser. Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified, so for security stuff we must not rely on JavaScript.

So when you make a HTTP request on server, the server first reads the PHP file carefully to see if there are any tasks that need to be executed, and sends a response to the client side. Again, as @deceze said, Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do so by reloading the page and sending a HTTP request
  2. You can make an AJAX call with JavaScript - this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming
Spelling corrected
Source Link
Alexander Nied
  • 13.8k
  • 4
  • 30
  • 50

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work.

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. theyThey reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

soSo you can easily see that server side language handle HTTP request andand process it and as @deceze said PHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed.

whileWhile at the other hand Client Side Language (like JavaScript) Resideresides on browser and runruns at the browser, Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not relayrely on JavaScript.

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to callcall PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. they reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

so you can easily see that server side language handle HTTP request and process it and as @deceze said PHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed

while at the other hand Client Side Language (like JavaScript) Reside on browser and run at the browser, Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not relay on JavaScript

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work.

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. They reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

So you can easily see that server side language handle HTTP request and process it and as @deceze said PHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed.

While at the other hand Client Side Language (like JavaScript) resides on browser and runs at the browser, Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not rely on JavaScript.

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. heythey reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

so you can easily see that server side language handle HTTP request and process it and as @deceze said PHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed

while at the other hand Client Side Language (like JavaScript) Reside on browser and run at the browser , Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not relay on JavaScript

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. hey reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

so you can easily see that server side language handle HTTP request and process it and as @deceze said PHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed

while at the other hand Client Side Language (like JavaScript) Reside on browser and run at the browser , Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not relay on JavaScript

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming

To determine why PHP code doesn't work in JavaScript code we need to understand what is client side and server side language and how they work

Server-side languages (PHP etc.): They retrieve records from databases, maintain state over the stateless HTTP connection, and do a lot of things that require security. they reside on the server, these programs never have their source code exposed to the user

Image from wikipedia_http://en.wikipedia.org/wiki/File:Scheme_dynamic_page_en.svg image attr

so you can easily see that server side language handle HTTP request and process it and as @deceze said PHP is executed on the server and outputs some HTML and maybe JavaScript code which is sent as response to the client where the HTML is interpreted and the JavaScript is executed

while at the other hand Client Side Language (like JavaScript) Reside on browser and run at the browser , Client-side scripting generally refers to the class of computer programs on the web that are executed client-side, by the user's web browser, instead of server-side.

JavaScript is visible to the user and can be easily modified so for security stuff we must not relay on JavaScript

So when you make a HTTP request on server than The server first reads the PHP file carefully to see if there are any tasks that need to be executed and send response to client side and again as @deceze said Once PHP has finished outputting the response, the script ends and nothing will happen on the server until a new HTTP request comes in.

Graphical representation

Image source

So now what can I do if I need to call PHP? It depends how you need to do it: either by reloading the page or by using an AJAX call.

  1. You can do by reloading page and send HTTP request
  2. you can make AJAX call with JavaScript and this does not require reloading page

Good Read:

  1. Wikipedia : Server-side scripting
  2. Wikipedia : Client-side scripting
  3. Madara Uchiha : Difference between client side and server side programming
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
Loading
replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot
Loading
added 10 characters in body
Source Link
AstroCB
  • 12.4k
  • 20
  • 59
  • 76
Loading
Loading
added 368 characters in body
Source Link
NullPoiиteя
  • 57.3k
  • 23
  • 130
  • 148
Loading
added 175 characters in body
Source Link
NullPoiиteя
  • 57.3k
  • 23
  • 130
  • 148
Loading
Source Link
NullPoiиteя
  • 57.3k
  • 23
  • 130
  • 148
Loading
default

AltStyle によって変換されたページ (->オリジナル) /