KennisbankExamencentrum
NL · NLNederlands (Nederland)
Taal kiezen13

CKTIS / PHP

Sleutelwoord do

Voert de lusinhoud uit vóór de voorwaarde wordt getest, zodat de lus minstens eenmaal begint.

Versie: PHP 8.4; repository runtime, production runtime not attested

Syntax

do { /* body */ } while ($condition);

Voert de lusinhoud uit vóór de voorwaarde wordt getest, zodat de lus minstens eenmaal begint. De voorwaarde regelt de herhaling. De puntkomma na de afsluitende while hoort bij de syntaxis.

$attempt=0; $seen=[];
do { $seen[]=++$attempt; } while ($attempt<0);
echo json_encode($seen);
[1]

Voorbeelden

<?php
$attempt=0; $seen=[];
do { $seen[]=++$attempt; } while ($attempt<0);
echo json_encode($seen);

Resultaat

[1]

Bronnen