473,378 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Public response to A Kaufman

Dear A Kaufman, I can't IMAGINE what you mean by this post in one previous
thread.

=================================================
"An include/require will be included no matter what.

For example:
<?php
if(TRUE){
include "myfile.php";
} else {
include "yourfile.php";
}
?>

In the above example - BOTH files will be included no matter what."
=================================================

This is NOT OF COURSE the case!

http://perttu.finote.com/muuta/test.php

Here I have in same folder files myfile.php and yourfile.php, other one
echoing
This text comes from file myfile.php
and other one echoing
This text comes from file yourfile.php

but OF COURSE test.php prints only "This text comes from file myfile.php"
Feb 1 '07 #1
4 1078
On 1 Feb, 11:14, "P Pulkkinen"
<perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.f iwrote:
Dear A Kaufman, I can't IMAGINE what you mean by this post in one previous
thread.

=================================================
"An include/require will be included no matter what.

For example:
<?php
if(TRUE){
include "myfile.php";} else {

include "yourfile.php";}

?>

In the above example - BOTH files will be included no matter what."
=================================================

This is NOT OF COURSE the case!

http://perttu.finote.com/muuta/test.php

Here I have in same folder files myfile.php and yourfile.php, other one
echoing
This text comes from file myfile.php
and other one echoing
This text comes from file yourfile.php

but OF COURSE test.php prints only "This text comes from file myfile.php"
He did not say that the contents of both files would be executed, he
said that both files would be included. The if/then/else statement
will ensure that the contents of yourfile.php do not get executed,
however they WILL be included.

Feb 1 '07 #2
P Pulkkinen wrote:
Dear A Kaufman, I can't IMAGINE what you mean by this post in one previous
thread.
My bad. I'm still thinking the old way.
I really wish I'd known they'd changed it - because this would
have come in handy a LOT over the last little while.

Here's the section from the PHP docs:

Note: Prior to PHP 4.0.2, the following applies: require()
will always attempt to read the target file, even if the line
it's on never executes. The conditional statement won't affect
require().
Feb 1 '07 #3
"Captain Paralytic" <pa**********@yahoo.comwrote in message
news:11********************@l53g2000cwa.googlegrou ps.com...
On 1 Feb, 11:14, "P Pulkkinen"
<perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.f iwrote:
>Dear A Kaufman, I can't IMAGINE what you mean by this post in one
previous
thread.

=============================================== ==
"An include/require will be included no matter what.

For example:
<?php
if(TRUE){
include "myfile.php";} else {

include "yourfile.php";}

?>

In the above example - BOTH files will be included no matter what."
=============================================== ==

This is NOT OF COURSE the case!

http://perttu.finote.com/muuta/test.php

Here I have in same folder files myfile.php and yourfile.php, other one
echoing
This text comes from file myfile.php
and other one echoing
This text comes from file yourfile.php

but OF COURSE test.php prints only "This text comes from file
myfile.php"

He did not say that the contents of both files would be executed, he
said that both files would be included. The if/then/else statement
will ensure that the contents of yourfile.php do not get executed,
however they WILL be included.
A proper way to test it might be including a HUGE (like Donald Trump Huge) a
file and see if there's a performance peak... like this:

<?php

$started = time();

if(FALSE){
require('my_huge_1Gb_bogus_file.php');
}
echo 'elapsed = '.(time()-$started);

?>

I'm thinking if elapsed time jumps thru the roof, then the file was accessed
and read into memory, but not executed thou. my_huge_1Gb_bogus_file.php
could just be <?php /* LOL OMG THIS IS A TEST LOL OMG THIS IS A TEST LOL OMG
THIS IS A TEST .... */ ?repeated a zillion times so that the file size
would actually become gigantic.

Another thing is that if you use require and a non-existing file, php
doesn't throw an error if the require statement is unreachable, like behind
if(FALSE), only when the file really is included in the code.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Feb 1 '07 #4

Another thing is that if you use require and a non-existing file, php
doesn't throw an error if the require statement is unreachable, like behind
if(FALSE), only when the file really is included in the code.
Sorry, people, to disturb you, but if php attempts to scan every
include()'d or require()'d file, how it deals with such construct?

if (false) {
$fileName = 'someFile.php';
include($fileName);
}

Even if include statement is processed, the $fileName var won't be
initialized before that point! I used such construct a lot, and
haven't get any errors or messages! Or even slowdonws! And you can
include/require you files in a loop, continiuosly changing the
filename or many other ways... so I think that PHP does not behave
that way, it does not process includes or requires that are not in the
execution thread.

Feb 2 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: motivus | last post by:
Hi. I am interested in tweaking Joshua Kaufman's CSS tabs GUI by, for example, offsetting the last tab from the preceding tabs. That is, putting a bigger space between the last two tabs so the...
7
by: John Grandy | last post by:
make a call to XML Web Service WebMethod ... returns object myArray with no error ... myArray contains objects of type StringKeyStringValue runtime error occurs on accessing properties of...
4
by: sviau | last post by:
should cache-control be set to public or private on dynamic site. our content doesnt change for 24hrs, but because results from search pages vary so much, we cant cache the pages themselves. ...
3
by: Moe Sizlak | last post by:
Hi There, I am trying to use the to obtain the information from 2 listmenus, if the user makes a selection the page is submitted and then based on the value selected is transfererd to another...
3
by: Tery | last post by:
I'm trying to implement the Handango.com HTTP POST registration method. The instructions are here: http://www.handango.com/marketing/developerTeam/HTTP_Post_Reg_Model_How2.doc I'm stuck on how...
5
by: xirowei | last post by:
i'm newbie in java servlet, how to let public void doPost can access to public void doGet, stringLength variable? below is my code: import javax.servlet.*; import javax.servlet.http.*; import...
1
by: Sebastian Paul | last post by:
Hi, the task is easy: I want to have the Cache-Control set to Public. void IHttpHandler.ProcessRequest(HttpContext context) { const int maxAge = 10;...
2
by: Web Search Store | last post by:
I am trying to make variables available in my web application by making user controls I classic asp I was able to put them all in an #include which made them available throughout the asp script...
11
by: Web Search Store | last post by:
Hello, I set up a web page with 2 user controls. In classic asp, the first one did all the declarations, and the second one used the values, and could reset it. In ASP.Net so far I can't...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.