Jump to content
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[résolu] [PHP] Truc bizarre pour initialisation

Featured Replies

Hello,

Un collègue vient de me soumettre un truc bizarre qu'il a rencontré en PHP. Voici un bout de code d'exemple pour illustrer le problème :

<?
$test	= 08;
$t2 	= 09;
echo "test=".gettype($test)."/".$test."<hr />";
echo "t2=".gettype($t2)."/".$t2."<hr />";
if ($test >= $t2) {
echo $test.">=".$t2;
} else {
echo $test."<".$t2;
}
?>

PHP me renvoit ça :

test=integer/0

--------------------------------------------------------------------------------

t2=integer/0

--------------------------------------------------------------------------------

0>=0

Je n'arrive pas à savoir pour PHP réagit comme ça.

C'est normal que les chiffres situés derrière un zéro ne soient pas pris en compte ?

Merci d'avance.

Edited by gvos_net

Quand tu précèdes un nombre d'un zéro, PHP interprète ça comme de l'octal, à savoir un système de représentation des nombre qui n'utilise que les caractères 0 à 7. De fait :

07 == 7
010 == 8

Mais 08 et 09 sont des choses qui n'ont pas de sens.

Il faut donc enlever les 0 qui précèdent pour que ton code marche. Sauf si la représentation est normalement octale, auquel cas '8' et '9' n'ont rien à faire dans le code de ton collègue. Mais je ne pense pas que ça soit le cas.

Archived

This topic is now archived and is closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.