0

good day! i'm a newbie in php. but i know the basic things like what is server side and what is client side. my question is is it "OK" if i place a php script (which is a server side) in the page that my client views? i dont know if this is a stupid question but please answer it im just soooo curious about this.

4
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by jjemphoung
0
<dtd with all the doo dah>
<html>
<head>
<!-- bla bla -->
</head>
<body>
<?php /* huge amount of php script, 
perfectly OK,  
user does not see the php, only the output of the script after it is completed */ 
echo '<p>this is visible</p>';
?>
<!-- more html -->
</body>
</html>

user sees

<dtd with all the doo dah>
<html>
<head>
<!-- bla bla -->
</head>
<body>
<p>this is visible</p>
<!-- more html -->
</body>
</html>

Edited by almostbob: n/a

0

hey thanks for the reply! soo php is not actually visible to the client. but isn't it a nice idea to separate client side from server side script? i mean in a client page, u must not place a server side script? isn't it a standard? i am totally new here. thanks for replying to my question hope u reply again! thank u very much such a big help really appreciate it!

0

The term server side and client side denotes from where the code is rendered or processed. Thats all!.

Actually there is no pages like client page or server page.
If you look at Mr.Rob's (almostbob) example you can see that he has included php script along with html which is client side.

When we check the page source we cannot see the php scripts. Because it will processed from server itself and then only it will be send to client side.
This is why we don't see any php scripts when viewing source code of an html page.

For a php page to work it must placed in its server.

Hope you got what you asked for.

0

NO it is not a good idea to separate scripts based on expected location, adds processing, http calls filesystem fetches
the only reason to code anything in any manner is to improve speed-reliability-security.
separate as external files, things that will get reused, css javascripts,
keep as internal to the file, things that are just for that file
There are php scripts made up of multiple external files,(PHPBB example, hundreds of script files) done that way for easy maintainence, improved usablility, upgradability
but somewhere, somehow, the scripts must output html or they do not display, you cant separate html from php completely
function is king, if what you do does not make it function better, dont do it.

0

Here is summary of what happens.
Client (mostly web browser) sends HTTP request to the server. The server processes the request with right file and then returns a response in terms of HTML or JSON et al.
So the Client doesn't know about server code and server about client. They only know of requests and response

see:
http://en.wikipedia.org/wiki/Server-side_scripting
http://www.killerphp.com/videos/serverside_programming_languages/serverside_programming_languages.html

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.