Jump to content


Photo

quick questions


  • Please log in to reply
9 replies to this topic

#1 sneskid

sneskid
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 14 April 2006 - 03:22 AM

1: Is Zend informed when a PHP file is updated or does it check the file every time someone accesses it?

2: What happens to scripts that are already running if their source PHP file is updated?

3: What happens to scripts that include another php file, and then the included file's source php gets updated? Can the script "re-include" that file again while running?

#2 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 14 April 2006 - 03:27 AM

Are you sure you understand how php works?

PHP is processed server side. Data is only sent to the browser after processing or until you break off from the php script.

Your script is not processing indefinitely. Everytime a script runs it loads all the includes called for it.

#3 sneskid

sneskid
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 14 April 2006 - 03:32 AM

[!--quoteo(post=364667:date=Apr 13 2006, 11:27 PM:name=jworisek)--][div class=\'quotetop\']QUOTE(jworisek @ Apr 13 2006, 11:27 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Are you sure you understand how php works?

PHP is processed server side. Data is only sent to the browser after processing or until you break off from the php script.

Your script is not processing indefinitely. Everytime a script runs it loads all the includes called for it.
[/quote]

I know the scripts don't run indefinately. They do what they do and then they stop. I'm just curious how the engine checks if a source file was updated, and how this effects scripts already running that were based on those source files.

if I have a file test.php and it has
<? php echo "one" ?>
when I go to it ill just see 1 on my browser window

If I update the file to be
<? php echo "two" ?>
and I go to it i should see 2 on my browser window, but sometimes this change takes a few seconds to happen.

I wanna know how PHP handles these updates.

#4 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 03:43 AM

PHP isn't compiled code, so it doesn't need to check for updates. Files will run regardless of their last updates, the Processor doesn't care about updates.

The update taking a few seconds could just be your cache loading the file. You should do a CTRL+Refresh when you update the files as it'll grab the latest copy of the file from the server.

C
The way to a mans stomach is through his heart.

#5 sneskid

sneskid
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 14 April 2006 - 03:54 AM

I know PHP code isn't actualy compiled, was just using that to get the idea accross. PHP is an interpreted language.

So does the php engine just keep re-enterpreting the file every time someone accesses it? Reading the file from HD every time?

#6 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 04:02 AM

yep, precisely.

Thats why its important to have well written code. Especially on big sites.

C
The way to a mans stomach is through his heart.

#7 sneskid

sneskid
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 14 April 2006 - 04:07 AM

ouchie

I was under the false impression the PHP engine keeps a "prepped&ready" copy of the script ready in memory... which would have been nice.

So then it would make sense to use short variable names and keep comments out of the final final draft.. right?

#8 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 04:13 AM

You can write code that is kept in a cache, but thats outside of my knowledge. I know you can build cached templates using things like smarty (http://smarty.php.net)
The way to a mans stomach is through his heart.

#9 sneskid

sneskid
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 14 April 2006 - 04:20 AM

thanks, you've been of great help

I just have one more question, a bit of an odd scenario.

Say file A includes another file B
Then file A spaws some object from a class file B provided
Then file A alters file B (actually edits it on the HD)
Then file A includes file B yet again... is this allowed, or will it cause some error?

#10 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 04:51 AM

hmmm, I have no idea.

I dont see why it wouldn't be permitted, providing the editting that takes place doesn't make a change to the way the files are called.... but, thats really a guess.
The way to a mans stomach is through his heart.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users