Jump to content
php.lv forumi

include


gingerfish

Recommended Posts

@Grey_Wolf tas tā ir kaut kādā tāvā sevišķajā php versijā vai varbūt php3 tā bija? :)

 

Vispār palasam manuāli: http://php.net/require

Vispār palasam manuali ;)

---

Handling Returns: It is possible to execute a return() statement inside an included file in order to terminate processing in that file and return to the script which called it. Also, it's possible to return values from included files. You can take the value of the include call as you would a normal function. This is not, however, possible when including remote files unless the output of the remote file has valid PHP start and end tags (as with any local file). You can declare the needed variables within those tags and they will be introduced at whichever point the file was included.

 

Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value.

--

Example #4 Comparing return value of include
<?php
// won't work, evaluated as include(('vars.php') == 'OK'), i.e. include('')
if (include('vars.php') == 'OK') {
   echo 'OK';
}

// works
if ((include 'vars.php') == 'OK') {
   echo 'OK';
}
?>

Example #5 include() and the return() statement
return.php
<?php

$var = 'PHP';

return $var;

?>

noreturn.php
<?php

$var = 'PHP';

?>

testreturns.php
<?php

$foo = include 'return.php';

echo $foo; // prints 'PHP'

$bar = include 'noreturn.php';

echo $bar; // prints 1

?>

--

ši ficha jau ir no, kaa minimums, no PHP4 versijas (par 3 nezinu)

Edited by Grey_Wolf
Link to comment
Share on other sites

Nu jā... tur rakstīts, ka 'include()' var darīt tā - kā parādīji, bet tas nav iespējams, ja fails atrodas ne-uz-Tava servera. Nekas par 'require()' netika minēts!

 

Tikai manuāli par 'include()'...

 

The documentation below also applies to require().
Link to comment
Share on other sites

Nu jā... tur rakstīts, ka 'include()' var darīt tā - kā parādīji, bet tas nav iespējams, ja fails atrodas ne-uz-Tava servera. Nekas par 'require()' netika minēts!

 

Tikai manuāli par 'include()'...

njaa.. tiko patesteeju ka 5 tas pats ir ar require(), 4 tas nestradaaja ..

Link to comment
Share on other sites

njaa.. tiko patesteeju ka 5 tas pats ir ar require(), 4 tas nestradaaja ..

 

Es tak saku! Par PHP 4 nemācēšu spriest... PHP 4 laikos vēl nezināju, kas vispār ir PHP. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...