Include Question!

Include Question!

am 09.05.2008 19:49:07 von Matthew Gonzales

So I am really cornfused about the include function.

If I use the include function to make my code readable and neat where
does the included code go. For instance:

if (some variable){
include(page.php);
}

Does the code go into the current page where the include statement is
located on the page. Hope that makes sense.

Matt G

--
Matthew Gonzales
IT Professional Specialist
Enterprise Information Technology Services
University of Georgia
Email: matt323@uga.edu
Phone: (706)542-9538

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Include Question!

am 09.05.2008 19:55:44 von Aaron Kenney

V2hhdCBpcyBpdCB0aGF0IHlvdSBhcmUgdHJ5aW5nIHRvIGFjY29tcGxpc2g/ IE5vcm1hbGx5IG5v
IGlmIHN0YXRlbWVudCBpcyBuZWVkZWQgZm9yIGFuIGluY2x1ZGUgdG8gdGFr ZSBwbGFjZSB1bmxl
c3MgYSBjZXJ0YWluIGNvbmRpdGlvbiB0cmlnZ2VycyB0aGUgdXNlIG9mIHRo ZSBpbmNsdWRlLg0K
U2VudCB2aWEgQmxhY2tCZXJyeSBmcm9tIFQtTW9iaWxlDQoNCi0tLS0tT3Jp Z2luYWwgTWVzc2Fn
ZS0tLS0tDQpGcm9tOiBNYXR0aGV3IEdvbnphbGVzIDxtYXR0MzIzQHVnYS5l ZHU+DQoNCkRhdGU6
IEZyaSwgMDkgTWF5IDIwMDggMTM6NDk6MDcgDQpUbzpQSFAtV2luZG93cyBH cm91cCA8cGhwLXdp
bmRvd3NAbGlzdHMucGhwLm5ldD4NClN1YmplY3Q6IFtQSFAtV0lOXSBJbmNs dWRlIFF1ZXN0aW9u
IQ0KDQpTbyBJIGFtIHJlYWxseSBjb3JuZnVzZWQgYWJvdXQgdGhlIGluY2x1 ZGUgZnVuY3Rpb24u
DQoNCklmIEkgdXNlIHRoZSBpbmNsdWRlIGZ1bmN0aW9uIHRvIG1ha2UgbXkg Y29kZSByZWFkYWJs
ZSBhbmQgbmVhdCB3aGVyZSANCmRvZXMgdGhlIGluY2x1ZGVkIGNvZGUgZ28u IEZvciBpbnN0YW5j
ZToNCg0KaWYgKHNvbWUgdmFyaWFibGUpew0KaW5jbHVkZShwYWdlLnBocCk7 DQp9DQoNCkRvZXMg
dGhlIGNvZGUgZ28gaW50byB0aGUgY3VycmVudCBwYWdlIHdoZXJlIHRoZSBp bmNsdWRlIHN0YXRl
bWVudCBpcyANCmxvY2F0ZWQgb24gdGhlIHBhZ2UuIEhvcGUgdGhhdCBtYWtl cyBzZW5zZS4NCg0K
TWF0dCBHDQoNCi0tIA0KTWF0dGhldyBHb256YWxlcw0KSVQgUHJvZmVzc2lv bmFsIFNwZWNpYWxp
c3QNCkVudGVycHJpc2UgSW5mb3JtYXRpb24gVGVjaG5vbG9neSBTZXJ2aWNl cw0KVW5pdmVyc2l0
eSBvZiBHZW9yZ2lhDQpFbWFpbDogbWF0dDMyM0B1Z2EuZWR1IDxtYWlsdG86 bWF0dDMyM0B1Z2Eu
ZWR1Pg0KUGhvbmU6ICg3MDYpNTQyLTk1MzgNCg0KLS0gDQpQSFAgV2luZG93 cyBNYWlsaW5nIExp
c3QgKGh0dHA6Ly93d3cucGhwLm5ldC8pDQpUbyB1bnN1YnNjcmliZSwgdmlz aXQ6IGh0dHA6Ly93
d3cucGhwLm5ldC91bnN1Yi5waHANCg0K

Re: Include Question!

am 09.05.2008 19:56:24 von Bradley Stahl

------=_Part_7373_19070707.1210355784664
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Your code would essentially be "inserted" in the place where your include
statement is called. Let's say that your in 'page.php' you had the
following code:

echo "I AM IN PAGE.PHP!";

and then in your script you have your code:

if (some variable) {
include('page.php');
}


This would essentially be giving you the code:

if(some variable) {
echo "I AM IN PAGE.PHP!";
}

I hope that this makes sense.. and this helps!

On Fri, May 9, 2008 at 1:49 PM, Matthew Gonzales wrote:

> So I am really cornfused about the include function.
>
> If I use the include function to make my code readable and neat where does
> the included code go. For instance:
>
> if (some variable){
> include(page.php);
> }
>
> Does the code go into the current page where the include statement is
> located on the page. Hope that makes sense.
>
> Matt G
>
> --
> Matthew Gonzales
> IT Professional Specialist
> Enterprise Information Technology Services
> University of Georgia
> Email: matt323@uga.edu
> Phone: (706)542-9538
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_7373_19070707.1210355784664--

Re: Include Question!

am 09.05.2008 20:05:27 von Stut

On 9 May 2008, at 18:56, Bradley Stahl wrote:
> Your code would essentially be "inserted" in the place where your
> include
> statement is called. Let's say that your in 'page.php' you had the
> following code:
>
> echo "I AM IN PAGE.PHP!";
>
> and then in your script you have your code:
>
> if (some variable) {
> include('page.php');
> }
>
>
> This would essentially be giving you the code:
>
> if(some variable) {
> echo "I AM IN PAGE.PHP!";
> }
>
> I hope that this makes sense.. and this helps!

That's not quite right and I think it's important to understand
exactly what PHP does here.

PHP is executing a file and encounters file inclusion (include/
require(_once)). PHP will load and compile the included file. During
this stage it registers declarations in the global scope, i.e. classes
and functions. After that it executes the included file in the same
context from which it was included, so all local vars visible inside
your if block will be accessible. Once that file's done PHP returns to
executing the original file from the statement after the include.

Note that no code insertion takes place, it purely passes execution to
the included file. It's this sequence that prevents you from defining
a class across several files.

Hope that makes it clearer.

-Stut

--
http://stut.net/

> On Fri, May 9, 2008 at 1:49 PM, Matthew Gonzales
> wrote:
>
>> So I am really cornfused about the include function.
>>
>> If I use the include function to make my code readable and neat
>> where does
>> the included code go. For instance:
>>
>> if (some variable){
>> include(page.php);
>> }
>>
>> Does the code go into the current page where the include statement is
>> located on the page. Hope that makes sense.
>>
>> Matt G
>>
>> --
>> Matthew Gonzales
>> IT Professional Specialist
>> Enterprise Information Technology Services
>> University of Georgia
>> Email: matt323@uga.edu
>> Phone: (706)542-9538
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php