text
stringlengths 1
254
| output
stringlengths 2
255
|
---|---|
PROPFIND, PROPPATCH, MOVE, COPY, etc..) If you want to get the post data of those requests, you have to set always_populate_raw_post_data as well.
|
PHPã¹ã¯ãªããã®äžã§WebDAV http ãªã¯ãšã¹ã (äŸïŒPROPFIND, PROPPATCH, MOVE, COPY, ç..)ã®åŠçãå¯èœã«ã㟠ãããããã®ãªã¯ãšã¹ãã®POSTããŒã¿ãååŸãããå Žåã always_populate_raw_post_data ãåæã«èšå®ããå¿
èŠãã ããŸãã
|
Table 4-6.
|
magic_quotes_gpc, magic-quotes-runtime, ããã³ magic_quotes_sybase ãåç
§äžããã
|
Name
|
衚 4-6ãã¹ããã³ãã£ã¬ã¯ããªèšå®ãªãã·ã§ã³
|
Here is a short explanation of the configuration directives.
|
以äžã«èšå®ãã£ã¬ã¯ãã£ãã«é¢ããç°¡åãªèª¬æã瀺ããŸãã
|
The format is like the system 's PATH environment variable: a list of directories separated with a colon in UNIX or semicolon in Windows.
|
require() ã include() ã ããã³ fopen_with_path() 颿°ããã¡ã€ã«ã æ¢ããã£ã¬ã¯ããªã®ãªã¹ããæå®ããŸãããã©ãŒãããã¯ãã·ã¹ã ã ã®ç°å¢å€æ° PATH ãšåãã§ããã€ãŸããUNIXã§ã¯ ã³ãã³ã§ãWindowsã§ã¯ã»ãã³ãã³ã§åºåã£ããã£ã¬ã¯ããªã®ãªã¹ã ã§æå®ããŸãã
|
Using a. in the include path allows for relative includes as it means the current directory.
|
äŸ 4-3UNIX include_path
|
Only used if non-empty.
|
äŸ 4-4Windows include_path
|
If PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root if you are running php as a CGI under any web server (other than IIS) The alternative is to use the cgi.force_redirect configuration below.
|
ãµãŒããŒã«ãããPHPã®"ã«ãŒããã£ã¬ã¯ããª"ã§ãããã®å€ã¯ç©ºã§ç¡ ãå Žåã®ã¿äœ¿çšãããŸããPHPã ã»ãŒ ãã¢ãŒã ã§èšå®ãããŠããå Žåã«ã¯ããã®ãã£ã¬ã¯ããªã®å€ åŽã«ãããã¡ã€ã«ã¯äœ¿çšãããŸããã PHPãFORCE_REDIRECTãæå®ããŠã³ã³ãã€ã«ãããŠããªãå Žåã (IIS以å€ã®)WebãµãŒãã®ããšã§CGIãšããŠPHPãå®è¡ããéã«ã¯ã doc_rootãæå®ããã¹ãã§ãã ä»ã®æ¹æ³ãšããŠã¯ãåŸè¿°ã® cgi.force_redirect èšå®ã®äœ¿çšããããŸãã
|
In what directory PHP should look for dynamically loadable extensions.
|
PHP ãã¡ã€ã«çšã«ãŠãŒã¶ãŒã®ããŒã ãã£ã¬ã¯ã ãªãšããŠäœ¿çšããåºæ¬ãã£ã¬ã¯ããªã®ååãäŸãã°ã public_html ãšãªããŸãã
|
cgi.force_redirect is necessary to provide security running PHP as a CGI under most web servers.
|
åçã«ããŒãå¯èœãªæ¡åŒµã¢ãžã¥ãŒã«ã眮ããã£ã¬ã¯ããªã æå®ããŸãã See also: enable_dl, and dl().
|
You can turn it off AT YOUR OWN RISK.
|
PHPã®éå§æã«ããŒãããåçã«ããŒãå¯èœãªæ¡åŒµã¢ãžã¥ãŒã«ã
|
To get OmniHTTPD or Xitami to work you MUST turn it off.
|
cgi.force_redirect ã¯ãã»ãšãã©ã®WebãµãŒãã®ããšã§CGIãšã㊠PHPãå®è¡ããéã®ã»ãã¥ãªãã£ã確ä¿ããããã«å¿
èŠã§ãã æªå®çŸ©ã®ãŸãŸã®å ŽåãPHPã¯ããã©ã«ãã§ãããonã«ããŸãã ãããoffã«ããããšãã§ããŸããã åèªã®ãªã¹ã¯ãšãªã ãŸãã
|
Note:
|
泚æ WindowsãŠãŒã¶: IISã§ã¯å®å
šã«ãããoffã«ããããšãã§ããŸãã å®éã«ã¯ãoffã«ããå¿
èŠããããŸãã OmniHTTPD ãŸã㯠Xitami ãåäœãããã«ã¯ããããoffã«ããå¿
èŠããããŸãã
|
FastCGI under IIS (on WINNT based OS) supports the ability to impersonate security tokens of the calling client.
|
cgi.force_redirect ã on ã«ããApache ãŸã㯠Netscape (iPlanet) WebãµãŒãã®ããšã§å®è¡ããŠããªãå Žåã å®è¡ãç¶ç¶ããŠè¯ããã©ãããPHPã倿ããããã« ç°å¢å€æ°ã®ååãèšå®ããå¿
èŠããããããããŸããã
|
Default is zero.
|
泚æ ãã®å€æ°ãèšå®ããããšã«ãããã»ãã¥ãªãã£äžã®åé¡ãçºçãã å ŽåããããŸããè¡ãããšã®ãªã¹ã¯ããŸãææ¡ããŠäžããã
|
File Uploads Configuration Options
|
IIS(ãŸãã¯WINNTããŒã¹ã®OS)ã®ããšã§ã®FastCGIã¯ã ã¯ã©ã€ã¢ã³ããã³ãŒã«ããéã«ã»ãã¥ãªãã£ããŒã¯ã³ã å¿ååããæ©èœããµããŒãããŠããŸãã ããã«ãããIISãé
äžã§ãªã¯ãšã¹ããå®è¡ããã»ãã¥ãªãã£ã³ã³ã ãã¹ããå®çŸ©ã§ããããã«ãªããŸããApacheã®ããšã§å®è¡ããã mod_fastcgiã¯çŸåšãã®æ©èœããµããŒãããŠããŸããã(03/17/2002) IISã®ããšã§å®è¡ããã«ã¯ã1ã«èšå®ããŠäžããã ããã©ã«ãã¯0ã§ãã
|
upload_max_filesize
|
衚 4-7ãã¡ã€ã«ã¢ããããŒãèšå®ãªãã·ã§ã³
|
Here is a short explanation of the configuration directives.
|
以äžã«èšå®ãã£ã¬ã¯ãã£ãã«é¢ããç°¡åãªèª¬æã瀺ããŸãã
|
See also the upload_max_filesize, upload_tmp_dir, and post_max_size directives.
|
HTTP ãã¡ã€ã«ã¢ããã㌠ã ãæå¹ãšãããã©ããã upload_max_filesize, upload_tmp_dir, post_max_size ãã£ã¬ ã¯ãã£ããåç
§äžããã
|
Must be writable by whatever user PHP is running as.
|
ãã¡ã€ã«ã¢ããããŒãæã«ãã¡ã€ã«ä¿åã«çšãããã³ãã©ãªãã£ã¬ ã¯ããªã PHP ã®å®è¡ãŠãŒã¶ãŒãæžããã¿å¯èœã§ ããå¿
èŠããããŸããæå®ãããªãå ŽåãPHPã¯ã·ã¹ãã ã®ããã©ã« ãèšå®ã䜿çšããŸãã
|
The maximum size of an uploaded file.
|
ã¢ããããŒãããããã¡ã€ã«ã®æå€§ãµã€ãºã
|
General SQL Configuration Options
|
衚 4-8SQLå
šè¬ã®èšå®ãªãã·ã§ã³
|
Here is a short explanation of the configuration directives.
|
以äžã«èšå®ãã£ã¬ã¯ãã£ãã«é¢ããç°¡åãªèª¬æã瀺ããŸãã
|
Port number used by the debugger.
|
ãããã¬ã«ãã䜿çšããããã¹ãã®DNSåãŸãã¯IPã¢ãã¬ã¹ã
|
Prev
|
ãããã¬ã«ãã䜿çšãããããŒãçªå·ã
|
How to change configuration settings
|
ãããã¬ãæå¹ã«ãããã©ããã
|
For the server module versions of PHP, this happens only once when the web server is started.
|
èšå®ãã¡ã€ã«(PHP 3.0ã§ã¯ php3.ini ãPHP 4.0 㧠㯠php.ini )ã¯ãPHP ã®èµ·åæã«èªã¿èŸŒãŸããŸãã PHPã®ãµãŒããŒã¢ãžã¥ãŒã«çã§ã¯ããã®ãã¡ã€ã«ã¯ãWeb ãµãŒããŒã®èµ·å æã«äžåºŠã ãèªã¿èŸŒãŸããŸãã CGI ãš CLI çã§ã¯ãèµ·åãã床ã«ãã®ãã¡ã€ã«ãèªã¿èŸŒãŸã ãŸãã
|
You can also use the environment variable PHPRC for an additional path to search for a php.ini file.
|
php.ini ã®ããã©ã«ãã®å Žæã¯ãã³ã³ãã€ã«æã®ãªãã·ã§ã³ã§ãã( FAQ ãšã³ããªãåç
§äž ããã) ãããã CGI ããã³ CLI çã®å Žåãã³ãã³ãã©ã€ã³ã¹ã€ãã -c ã«ããããã倿Žããããšãã§ããŸãã ã³ãã³ãã©ã€ã³ ããã® PHP ã®äœ¿çšã«é¢ããç« ãåç
§äžããã php.ini ãæ¢ããã¹ã远å ããããã«ç°å¢å€æ° PHPRC ã䜿çšããããšãã§ããŸãã
|
You may want to view the latest php.ini here from CVS.
|
泚æ PHPãã£ã¬ã¯ãã£ã register_globals ã®ããã©ã«ãå€ã¯ã PHP 4.2.0 以é on ãã off ã«å€æŽãããŠããŸãã
|
Example 4-1. php.ini example
|
äŸ 4-1 php.ini ã®äŸ
|
In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.
|
PHPã¯ãããã€ãã®å¶åŸ¡æ§é ãã€ãŸãã if ã while ã for ã foreach ã switch ã«é¢ããå¥ã®æ§æãæäŸããŸãã åæ§é ã«ãããŠéãæ³¢æ¬åŒ§ãã³ãã³(:)ãéãæ³¢æ¬åŒ§ããããã endif;, endwhile;, endfor;, endforeach;, endswitch; ã«å€æŽããã®ã å¥ã®æ§æã®åºæ¬çãªåœ¢åŒãšãªããŸãã
|
The HTML block would be displayed only if $a is equal to 5.
|
äžã®äŸã§ã¯ãHTMLãããã¯"A = 5"ã¯ãã®æ§æã§ æžããã if æã®å
éšã§å
¥ãåã«ãªã£ãŠããŸãã ãã®HTMLãããã¯ã¯ã$aã5ã®å Žåã«ã®ã¿è¡šç€ºãããŸãã
|
if ($a == 5): print "a equals 5"; print ".. ."; elseif ($a == 6): print "a equals 6"; print "!! !"; else: print "a is neither 5 nor 6"; endif;
|
ãã®æ¹æ³ã¯ã else ã elseif ã«ã åæ§ã«é©çšããããšãã§ããŸãã æ¬¡ã®äŸã¯ããã®åœ¢åŒã§ if æã elseif ããã³ else ãšå
±ã«äœ¿çšããŠããŸãã
|
Prev
|
ããå€ãã®äŸãåç
§ããã«ã¯ã while, for, if ãåç
§äžããã
|
break ends execution of the current for, foreach while, do..while or switch structure.
|
break ã¯ãçŸåšå®è¡äžã® for, foreach while, do..while, switch æ§é ã®å®è¡ãçµäºããŸãã
|
continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of.
|
continue ã¯ãã«ãŒãæ§é ã«ãããŠçŸåšã®ç¹°ãè¿ãã«ãŒã ã®æ®ãã®åŠçãã¹ãããããæ¬¡ã®ç¹°ãè¿ãã®æåããå®è¡ãç¶ãããã㫠䜿çšãããŸãã
|
Prev
|
continue ã§ã¯ããªãã·ã§ã³ã®åŒæ°ã§ åŠçãã¹ãããããã«ãŒãæ§é ã®ã¬ãã«ã®æ°ãæå®ã§ããŸãã
|
The syntax of declare is similar to the syntax of other flow control constructs:
|
declare åœä»€ã¯ãããã³ãŒããããã¯ã®äžã« å®å¹åœä»€ãã»ããããããã«äœ¿çšãããŸãã declare ã®ææ³ã¯ä»ã®å¶åŸ¡æ§é ãšäŒŒãŠããŸãã
|
Currently only one directive is recognized: the ticks directive. (See below for more information on the ticks directive)
|
åœä»€ ã®ç®æã§ãã»ããããã declare ãããã¯ã®æåãæå®ããããšãåºæ¥ãŸãã çŸåšã®ãšããã䜿çšã§ããåœä»€ã¯ ticks ã® äžã€ã ãã§ãã( ticks ã«é¢ããŠã¯ä»¥äžãåç
§ããŠãã ãã)
|
The statement part of the declare block will be executed - - how it is executed and what side effects occur during execution may depend on the directive set in the directive block.
|
declare ãããã¯ã® æ ã®å®è¡ã®ããæ¹ãå®è¡æã«ã©ã®ãããªäœçšãèµ·ãããã«ã€ããŠã¯ åœä»€ ã«äœãæå®ããããã«äŸåããŸãã
|
The value for N is specified using ticks= N within the declare blocks' s directive section.
|
tickãšã¯ declare ãããã¯ã®å®è¡äžã«ããŒãµã N åã®äœã¬ãã«åœä»€ãå®è¡ããããšã« çºçããã€ãã³ãã®ããšã§ãã N ã®å€ã¯ declare ãããã¯ã® åœä»€ ã®ç®æã§ ticks= N ã®ããã« æå®ããŸãã
|
See the example below for more details.
|
tickããšã«çºçãããã€ãã³ã㯠register_tick_function() ã䜿çšããŠæå®ããŸãã詳现ã¯ä»¥äžã®äŸãåç
§ããŠãã ããã1åã®tickã§ è€æ°ã®ã€ãã³ããèµ·ããåŸãããšã«æ³šæããŠãã ããã
|
Example 12-1.
|
äŸ 12-1PHPã®ã³ãŒãã®äžéšããããã¡ã€ã«ãã
|
Ticks are well suited for debugging, implementing simple multitasking, backgrounded I / O and many other tasks.
|
ticksã¯ãããã°ãåçŽãªãã«ãã¿ã¹ã¯åŠçãããã¯ã°ã©ãŠã³ãI/Oã ãã®ä»å€ãã®åŠçãå®è£
ããã®ã«äŸ¿å©ã§ãã
|
Prev
|
register_tick_function() ãš unregister_tick_function() ãåç
§ããŠãã ããã
|
$i = 0; do {print $i;} while ($i 0);
|
do..while ã«ãŒãã®æ§æã¯æ¬¡ã®äžã€ã®ã¿ã§ãã
|
Advanced C users may be familiar with a different usage of the do..while loop, to allow stopping execution in the middle of code blocks, by encapsulating them with do..while (0), and using the break statement.
|
äžèšã®ã«ãŒãã¯å¿
ãäžåºŠã ãå®è¡ãããŸãããã®åå ã¯ãæåã®å埩ã®åŸã è«çå€ã®ãã§ãã¯ãè¡ã£ãéã«å€ã FALSE ãš ãªã($iã¯0ãã倧ãããªã)ãã«ãŒãã®å®è¡ãçµäºããããã§ãã
|
do {if ($i 5) {print "i is not big enough"; break;} $i *= $factor; if ($i $minimum_limit) {break;} print "i is ok"; ...process i...} while(0);
|
åªããCããã°ã©ãã¯ãã³ãŒããããã¯äžã§ã®å®è¡äžæ¢ãå¯èœãª do..while ã«ãŒãã®å¥ã®äœ¿çšæ³ã«ã€ããŠçç¥ããŠãã ãããããŸããã ããã¯ã do..while (0)ã§ã³ãŒããæ¬ãã break æã䜿çšããæ¹æ³ã§ããæ¬¡ã®ã³ãŒãã¯ããã®æ¹æ³ã®äŸã瀺ããŠããŸãã
|
You can code scripts and even powerful scripts without using this' feature '.
|
ãã®äŸãããã«çè§£ã§ããªãã£ãããå
šãçè§£ã§ããªãã£ããããŠã åé¡ãããŸããããã®'æ©èœ'ã䜿çšããªããŠã ã¹ã¯ãªããã³ãŒããæžãããšãã§ããŸããã匷åãªã¹ã¯ãªããã§ãã äœæããããšãå¯èœã§ãã
|
This is what else is for. else extends an if statement to execute a statement in case the expression in the if statement evaluates to FALSE.
|
ããæ¡ä»¶ãæºããããŠããå Žåã«ããæãå®è¡ãã ãã®æ¡ä»¶ãæºããããŠããªãå Žåã«å¥ã®æãå®è¡ããããšèãã ããšã床ã
ããããšæããŸãã ãã®ããã« else ããããŸãã else ã¯ã if æã«ãããåŒã®å€ã FALSE ã®å Žåã«ããæã å®è¡ããããã« if æãæ¡åŒµããŸãã äŸãã°ã次ã®ã³ãŒãã¯ã $a ã $b ããã倧ããå Žåã« aã¯bãã倧ãã ãšè¡šç€ºãã ããã§ãªãå Žåã«ã aã¯bããã倧ãããªã ãšè¡šç€ºããŸãã
|
However, unlike else, it will execute that alternative expression only if the elseif conditional expression evaluates to TRUE.
|
elseif ã¯ããã®ååããåããããã«ã if ãš else ã®çµã¿åããã§ãã elseif ã¯ã else ã®ããã«ãå
ã® if åŒã®å€ã FALSE ã®å Žåã«å¥ã®æãå®è¡ããããã« if æãæ¡åŒµããŸãã ãããã else ãšã¯ç°ãªãã elseif åŒã TRUE ã®å Žåã«ã®ã¿ä»£ããã®åŒãå®è¡ããŸãã äŸãã°ã次ã®ã³ãŒãã¯ã aã¯bãã倧ãã ã aã¯bã«çãã ã aã¯bããå°ãã ãåºåããŸãã
|
The syntactic meaning is slightly different (if you're familiar with C, this is the same behavior) but the bottom line is that both would result in exactly the same behavior.
|
è€æ°ã® elseif ãåã if æã®äžã§ 䜿çšããããšãã§ããŸãã TRUE ãšè©äŸ¡ãããæåã® elseif åŒ ãå®è¡ãããŸããPHPã§ã¯ã(åèªäºã€ã§)'else if'ãšæžãããšãã§ããŸãã åäœã¯(äžåèªã®) 'elseif'ãšåãã§ããææ³çãªæå³ã¯ããç°ãªã£ãŠããŸãã (ããªãã C èšèªã«è©³ãããšãããšãC èšèªã®ãããšåãåäœã§ãã) ããããæçµçãªäž¡è
ã®åäœã¯å
šãåãã§ãã
|
Prev
|
elseif æã¯ãåã«ããå
šãŠã® if æãš elseif ã®å€ã FALSE ã§ããã ã«ã¬ã³ãã® elseif åŒã®å€ã TRUE ã§ãã å Žåã«ã®ã¿å®è¡ãããŸãã
|
This simply gives an easy way to iterate over arrays. foreach works only on arrays, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variables.
|
(PHP 3ã§ã¯ãªã)PHP 4ã«ã¯ãPerlãä»ã®èšèªãšãã䌌ã foreach æ§æããããŸããããã«ãã é
åèŠçŽ ã«é¢ããå埩åŠçã容æã«ãªããŸãããã®æ§é ã«ã¯ã 2çš®é¡ã®æ§æããããŸãã2çªç®ã®æ§æã¯ããŸãç¥ãããŠããŸãããã æåã®æ§æã®äŸ¿å©ãªæ¡åŒµã«ãªã£ãŠããŸãã
|
On each loop, the value of the current element is assigned to $value and the internal array pointer is advanced by one (so on the next loop, you'll be looking at the next element).
|
æåã®åœ¢åŒã¯ã array_expression ã§æå®ããé
åã« é¢ããŠã«ãŒãåŠçãè¡ããŸããåã«ãŒãã«ãããŠçŸåšã®èŠçŽ ã®å€ã $value ã«ä»£å
¥ãããå
éšé
åãã€ã³ã¿ãäžã€åã« é²ããããŸãã(ãã£ãŠã次ã®ã«ãŒãã§ã¯æ¬¡ã®èŠçŽ ãèŠãããšã«ãªããŸãã)
|
The second form does the same thing, except that the current element 's key will be assigned to the variable $key on each loop.
|
2çªç®ã®åœ¢åŒãåæ§ã§ãããåã«ãŒãã§çŸåšã®èŠçŽ ã®ããŒã倿° $key ã«ä»£å
¥ããããšãããç°ãªããŸãã
|
This means that you do not need to call reset() before a foreach loop.
|
泚æ foreach ã®å®è¡éå§æã«å
éšé
åãã€ã³ã¿ã¯ã é
åã®å
é èŠçŽ ãæãããã«èªåçã«ãªã»ãããããŸãã ãã®ããã foreach ã«ãŒãã®åã« reset() ãã³ãŒã«ããå¿
èŠã¯ãããŸããã
|
However, the internal pointer of the original array is advanced with the processing of the array.
|
泚æ foreach ã¯ãæå®ããé
åèªäœã«å¯ŸããŠã§ã¯ãªãã ãã®ã³ããŒã«å¯ŸããŠåŠçãè¡ãããšã«æ³šæããŠäžããããã®ããã each() æã®ããã«é
åã®ãã€ã³ã¿äœçœ®ã倿Žãã ãããšã¯ãªããè¿ãããé
åèŠçŽ ãžã®å€æŽã¯ãå
ã®é
åã«ã¯åæ ãã㟠ããã
|
You may have noticed that the following are functionally identical:
|
泚æ foreach ã¯ã'@' ã«ãããšã©ãŒã¡ãã»ãŒãžåºåãæ å¶ããæ©èœããµããŒãããŠããŸããã
|
reset ($arr); while (list($key, $value) = each ($arr)) {echo "Key: $key; Value: $value br \n";} foreach ($arr as $key = $value) {echo "Key: $key; Value: $value br \n";}
|
æ¢ã«ãåç¥ããšæããŸããã以äžã®æã¯æ©èœçã«ç䟡ã§ãã
|
Home
|
äœ¿çšæ³ã瀺ãããã«ãã®ä»ã®äŸã瀺ããŸãã
|
In the beginning of each iteration, expr2 is evaluated.
|
for ã«ãŒãã¯ãPHPã§æãè€éãªã«ãŒãã§ãã for ã¯ãCã®forã«ãŒããšåæ§ã«åäœããŸãã for ã«ãŒãã®æ§æã¯ã次ã®ããã«ãªããŸãã
|
If it evaluates to FALSE, the execution of the loop ends.
|
æåã®åŒ( åŒ1 )ã¯ãã«ãŒãéå§æã«ç¡æ¡ä»¶ã« è©äŸ¡(å®è¡)ãããŸãã
|
This may not be as useless as you might think, since often you 'd want to end the loop using a conditional break statement instead of using the for truth expression.
|
åç¹°ãè¿ãã®éå§æã«ã åŒ2 ãè©äŸ¡ãããŸãã ãã®åŒã®å€ã TRUE ãå Žåãã«ãŒãã¯ç¶ç¶ãããæ¬åŒ§ å
ã®æãå®è¡ãããŸããå€ã FALSE ã®å Žåãã«ãŒãã® å®è¡ã¯çµäºããŸãã
|
All of them display numbers from 1 to 10:
|
åç¹°ãè¿ãã®åŸã åŒ3 ãè©äŸ¡(å®è¡)ãããŸãã
|
Of course, the first example appears to be the nicest one (or perhaps the fourth), but you may find that being able to use empty expressions in for loops comes in handy in many occasions.
|
ååŒã¯ã空ãšããããšãã§ããŸãã åŒ2 ã空 ã«ããããšã¯ãç¡éå®è¡ã«ãŒããæå³ããŸãã(PHPã¯ããã®ç¶æ
ãCèšèª ã®ããã«æé»ã®å
ã« TRUE ãšã¿ãªããŸã) for è«çåŒã䜿çšãããããæ¡ä»¶ä» break æã«ããã«ãŒããçµäºãããæ¹ã奜ãŸããå Žåã«ã¯ããã®æ©èœã¯æã£ã ã»ã©äŸ¿å©ã§ã¯ãªããããããŸããã
|
for (expr1; expr2; expr3): statement;...; endfor;
|
次ã®äŸã«ã€ããŠèããŠã¿ãŸãããã以äžã®äŸã¯å
šãŠ1ïœ10ãŸã§ã®æ°ã衚瀺ããŸãã
|
PHP 3 has no such construct; PHP 4 does (see foreach).
|
ãã¡ãããæåã®äŸ(ããã㯠4çªç®ã®äŸ)ãæåã§ãããšèããããŸãã ãããã for ã«ãŒãã«ãããŠç©ºã®åŒã䜿çšã§ãããšã å€ãã®å Žåã䟿å©ã ãšããããšã«æ°ã¥ãããããšæããŸãã
|
See the documentation for these functions for an example.
|
PHPã¯ã for ã«ãŒãçšã«"ã³ãã³æ§æ"ããµããŒãããŸãã
|
Home
|
ä»ã®èšèªã«ã¯ãé
åãããã·ã¥ãé£ç¶çã«åŠçããããã« foreach æããããŸããPHP 3ã«ã¯ãããã æ§æã¯ãããŸãããPHP 4ã¯ããããµããŒãããŠããŸãã (foreach ãåç
§äžãã) PHP 3 ã§ã¯ãåæ§ã®å¹æãåŸãããã« while æã list() ããã³ each() ãšçµã¿åãããŠäœ¿çšããŸãã äŸã«ã€ããŠã¯ããããã®é¢æ°ã«é¢ããããã¥ã¡ã³ããåç
§äžããã
|
A statement can be an assignment, a function call, a loop, a conditional statement of even a statement that does nothing (an empty statement).
|
å
šãŠã®PHPã¹ã¯ãªããã¯ãäžé£ã®æãããªããŸãã æãšããŠã¯ã代å
¥ã颿°ã³ãŒã«ãã«ãŒããæ¡ä»¶æããããŠãäœãããªãæ(ç©ºã®æ) ãã䜿çšããããšãã§ããŸãã æã¯ãéåžžã»ãã³ãã³ã§çµäºããŸããå ããŠãæã¯ãäžæ¬åŒ§ã«ããã°ã«ãŒãæã§ ã«ãã»ã«åããããšã«ããã°ã«ãŒãåããããšãå¯èœã§ãã ã°ã«ãŒãæã¯ãåæã«æã«ããªããŸãã æ¬ç« ã§ã¯ãæ§ã
ãªæã®åãèšè¿°ãããŠããŸãã
|
A statement-group is a statement by itself as well.
|
if æ§æã¯ãPHP ãå«ãå
šãŠã®èšèªã«ãããŠæãéèŠãª æ©èœã®äžã€ã§ãã ãã®æ§æã¯ãåœä»€ã®æ¡ä»¶å®è¡ãå¯èœã«ããŸãã PHPã§ã¯ã次ã®ãããªCèšèªã«äŒŒã if æ§æã䜿çšãããŸãã
|
More information about what values evaluate to FALSE can be found in the 'Converting to boolean' section.
|
åŒã®ã»ã¯ã·ã§ã³ ã§ èšè¿°ããããã« åŒ ã¯è«çå€ã§è©äŸ¡ãããŸãã åŒ ã TRUE ãšè©äŸ¡ãããå Žåã PHP㯠æ ãå®è¡ããŸãã FALSE ãšè©äŸ¡ãããå Žåã¯ããããç¡èŠããŸããã©ã®ãããªå€ã FALSE ãšè©äŸ¡ãããã«ã€ããŠã¯ è«çå€ãžã®å€æ ãåç
§ããŠãã ããã
|
Of course, there 's no need to wrap each statement with an if clause.
|
以äžã®äŸã¯ã $a ã $b ãã倧ããå Žåã aã¯bãã倧ãã ã衚瀺ããŸãã
|
For example, this code would display a is bigger than b if $a is bigger than $b, and would then assign the value of $a into $b:
|
æ¡ä»¶åå²ããããæãäžã€ä»¥äžããå Žåããã°ãã°ãããŸãã ãã¡ãããåã
ã®æã if æã§æ¬ãå¿
èŠã¯ãããŸããã 代ããã«ãè€æ°ã®æãã°ã«ãŒãåããããšãã§ããŸãã äŸãã°ããã®ã³ãŒãã¯ã $a ã $b ããã倧ããå Žåã« aã¯bããã倧ãã ã衚瀺ãã $a ã®å€ã $b 㫠代å
¥ããŸãã
|
If statements can be nested indefinitely within other if statements, which provides you with complete flexibility for conditional execution of the various parts of your program.
|
ifæã¯ãä»ã® if æã®äžã§ç¡éã«å
¥ãåã«ã§ããŸãã ããã¯ãããã°ã©ã ã®æ§ã
ãªéšåã®æ¡ä»¶ä»å®è¡ã«ã€ã㊠å®å
šãªæè»æ§ãæäŸããŸãã
|
In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to.
|
switch æã¯ãåãåŒãçšããŠIFæã䞊ã¹ãã®ã«äŒŒãŠããŸãã åã倿°ãç°ãªãå€ãšæ¯èŒããå€ã«å¿ããŠç°ãªã£ãã³ãŒããå®è¡ããããš æãããšããã°ãã°ããããšæããŸãã switch æã¯ããŸãã«ãã®ããã«ããã®ã§ãã
|
The following two examples are two different ways to write the same thing, one using a series of if statements, and the other using the switch statement:
|
次ã®äºã€ã®äŸã¯ãåãããšãäºã€ã®ç°ãªã£ãæ¹æ³ã§æžãããã®ã§ãã äžã€ã¯ã if æããããäžã€ã¯ switch æã䜿ã£ãŠããŸãã
|
It is important to understand how the switch statement is executed in order to avoid mistakes.
|
倱æãé¿ããããã« switch æãã©ã®ããã«å®è¡ãããã®ãã çè§£ããããšãéèŠã§ãã switch æã¯ãè¡æ¯ã«å®è¡ãããŸãã (å®éã«ã¯ãææ¯ã«å®è¡ãããŸãã)åãã¯ãäœãå®è¡ããŸããã switch åŒã®å€ãšäžèŽããå€ãæãã case æãèŠã€ãããããšãã«åããŠPHã«ãã åœä»€ã®å®è¡ãè¡ãããŸãã PHP㯠switch ãããã¯ã®çµãããŸãã¯æåã® break æãŸã§å®è¡ãç¶ããŸãã CASEæã®çµããã« break æãæžããªãå Žåã¯ãPHP㯠次ã®CASEæãå®è¡ãã€ã¥ããŸããäŸãã°ã
|
PHP continues to execute the statements until the end of the switch block, or the first time it sees a break statement.
|
ããã§ã$iã0ã«çããå Žåã¯ãPHPã¯å
šãŠã®æãåºåããŠããŸããŸã! $iã1ã®å ŽåãPHPã¯æåŸã®äºã€ã®æãåºåããŸãã $iã2ã«çããå Žåã®ã¿ã'æåŸ
ãã'åäœããã'iã¯2ã«çãã'ãšè¡šç€ºããŸãã ãã®ããã(ããçš®ã®ç¶æ³äžã§ã¯ãBREAKãä»å ããããšãé¿ããããš æããããããŸãããã) break æãå¿ããªãããã«ããããšãéèŠã§ãã
|
In a switch statement, the condition is evaluated only once and the result is compared to each case statement.
|
switch æã§ã¯ãæ¡ä»¶ã¯1床ã ãè©äŸ¡ããã ãã®çµæãå case æãšæ¯èŒãããŸãã elseif æã§ã¯ãæ¡ä»¶ã¯ãå床è©äŸ¡ãããŸãã 䜿çšããæ¡ä»¶ãåçŽãªæ¯èŒåŠçãããè€éãªåŠçãè¡ã£ããã éãç¹°ãè¿ãåŠçãè¡ãå Žåã switch ã®æ¹ã ããåŠçãéãå¯èœæ§ããããŸãã
|
If your condition is more complicated than a simple compare and / or is in a tight loop, a switch may be faster.
|
caseã«ä»éããæã¯ã空ãšããããšãå¯èœã§ãã ãã®å Žåãæ¬¡ã®caseã«ä»éããæã«å¶åŸ¡ãç§»è¡ããŸãã
|
switch ($i) {case 0: case 1: case 2: print "i is less than 3 but not negative"; break; case 3: print "i is 3";}
|
defaultã¯ãcaseæã®ç¹å¥ãªå Žåã§ããããã¯ä»ã®å
šãŠã®caseã« ãããããªãå Žåã«å®è¡ãããæåŸã® case æã«çœ® ãå¿
èŠããããŸããäŸã以äžã«ç€ºããŸãã
|
The case expression may be any expression that evaluates to a simple type, that is, integer or floating-point numbers and strings.
|
case åŒã¯ãã¹ã«ã©ãŒåã«åŒãè©äŸ¡ãã ä»»æã®åŒãã€ãŸããæŽæ°ãæµ®åå°æ°ç¹ãæååãšããããšãã§ããŸãã é
ååã¯ãªããžã§ã¯ãã¯ãåçŽãªåã«ãã£ã¹ããããŠããªãéã 䜿çšããããšãã§ããŸããã
|
switch ($i): case 0: print "i equals 0"; break; case 1: print "i equals 1"; break; case 2: print "i equals 2"; break; default: print "i is not equal to 0, 1 or 2"; endswitch;
|
switchæã®å¶åŸ¡æ§é ã«é¢ããå¥ã®æ§æããµããŒããããŠããŸãã 詳现ã¯ã å¶åŸ¡æ§é ã«é¢ããå¥ã®æ§æ ãåç
§äžããã
|
It tells PHP to execute the nested statement( s) repeatedly, as long as the while expression evaluates to TRUE.
|
while ã«ãŒãã¯ãPHPã§æãç°¡åãªã¿ã€ãã®ã«ãŒãã§ãã ãã®ã«ãŒãã¯ãCã®WHILEã«ãŒããšåæ§ã®åäœãããŸãã while ã«ãŒãã®åºæ¬åœ¢ã¯æ¬¡ã®ããã«ãªããŸãã
|
Sometimes, if the while expression evaluates to FALSE from the very beginning, the nested statement( s) won't even be run once.
|
while æã®æå³ã¯ç°¡åã§ãã while æã¯ãåŒã®å€ã TRUE ã§ããéã å
¥ãåã®æãç¹°ãè¿ãå®è¡ããããšãPHPã«æç€ºããŸãã åŒã®å€ã¯åå埩åŠçã®éå§æã«ãã§ãã¯ãããã®ã§ãã«ãŒãå
ã®æã®å®è¡ã«ãã ãã®å€ã代ãã£ãå Žåã§ãã«ãŒãå®è¡ã¯åã«ãŒããçµããŸã§çµãããŸããã (PHPã«ããã«ãŒãå
ã®æã®å®è¡ã1ååã®å埩ã«çžåœããŸã) while åŒã®å€ãåããã FALSE ã® å Žåã¯ãå
éšã®æã¯äžåãå®è¡ãããŸããã
|
while (expr): statement... endwhile;
|
if æãšåæ§ã«ãæ³¢æ¬åŒ§ã§è€æ°ã®æãå²ããã 以äžã«ç€ºãå¥ã®æ§æãçšããããšã«ãããåã while ã«ãŒãã®äžã«è€æ°ã®æãã°ã«ãŒãåããããšãã§ããŸãã
|
/* example 1 * / $i = 1; while ($i = 10) {print $i++; / * the printed value would be $i before the increment (post-increment) * /} / * example 2 * / $i = 1; while ($i = 10): print $i; $i++; endwhile;
|
次ã®äŸã¯åãã§ããäž¡æ¹å
±ã1ãã10ãŸã§ã®æ°ãåºåããŸãã
|
Copyright
|
èäœæš©
|
The members of this group are listed on the front page of this manual.
|
æ¬ããã¥ã¢ã«ã¯ã © Copyright 1997, 1998, 1999, 2000 ,2001, 2002 the PHP Documentation Group ãèäœæš©ãä¿æããŠããŸãã æ¬ããã¥ã¢ã«ã®å
é ããŒãžã«æ¬ã°ã«ãŒãã®ã¡ã³ããŒäžèЧããããŸãã
|
This manual can be redistributed under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
æ¬ããã¥ã¢ã«ã¯ãFree Software Foundation ãå
¬éãã GNU General Public License (ã©ã€ã»ã³ã¹ç¬¬2çããŸãã¯ãã以é) ã«åºã¥ããŠåé
åžããããšãã§ããŸãã
|
This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http: / /www.opencontent.org / openpub /).
|
ãã®ããã¥ã¢ã«ã®ã»ã¯ã·ã§ã³'Extending PHP 4.0'ã®èäœæš©ã¯Â© 2000 Zend Technologies, Ltdã«ãããŸãããã®ææžã¯Open Publication License, v1.0ãããã¯ãã以éã«åºã¥ãéãã«ãããŠé
åžããããšã åºæ¥ãŸã(ææ°çã¯çŸåš http://www.opencontent.org/openpub/) ããæã«å
¥ããããšãåºæ¥ãŸã)ã
|
PHP 4 does not have an internal debugging facility.
|
PHP 3ã§ã¯ãããã¯ãŒã¯å¯Ÿå¿ã®ãããã¬ããµããŒããããŠããŸãã
|
Each message starts with a line of the type start and terminates with a line of the type end.
|
PHP 3ã®ãããã¬ã®ãããã³ã«ã¯è¡ããŒã¹ã§ããåè¡ã«ã¯ ã¿ã€ã ãæã¡ããŸã ã¡ãã»ãŒãž ãæ§æããè¡ããããŸããåã¡ãã»ãŒãžã¯ã¿ã€ã start ãæã€è¡ã§å§ãŸããã¿ã€ã end ãæã€ è¡ã§çµãããŸããPHP 3ã¯ç°ãªã£ãã¡ãã»ãŒãžãæã€è¡ãåæã«éãããšã ãããŸãã
|
A line has this format:
|
åè¡ã®ãã©ãŒãããïŒ
|
Date in ISO 8601 format (yyyy - mm - dd)
|
æ¥ä» æå» ãã¹ã (ããã»ã¹ID) ã¿ã€ã: ã¡ãã»ãŒãžããŒã¿
|
Time including microseconds: hh: mm: uuuuuu
|
ISO 8601ãã©ãŒãããã®æ¥ä» (yyyy - mm - dd)
|
DNS name or IP address of the host where the script error was generated.
|
ãã€ã¯ãç§åäœã®æå»: hh: mm: uuuuuu
|
PID (process id) on host of the process with the PHP 3 script that generated this error.
|
ã¹ã¯ãªããã»ãšã©ãŒãçæãããã¹ãã®DNSå ãŸãã¯IPã¢ãã¬ã¹ã
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.