PHP-Logo

PHP-Kurs


Funktionen : Mathe

hexdec

hexdec( ) ist eine mathematische Funktion.
Sie rechnet Zahlen-Werte aus dem Hexadezimalsystem in das Dezimalsystem um.

1<?php
2
3$hex_ff = "ff";
4$dec_ff = hexdec($hex_ff);
5echo $hex_ff." -> ";
6echo $dec_ff."<br>";
7
8$hex_ee = "ee";
9$dec_ee = hexdec($hex_ee);
10echo $hex_ee." -> ";
11echo $dec_ee."<br>";
12
13$hex_dd = "dd";
14$dec_dd = hexdec($hex_dd);
15echo $hex_dd." -> ";
16echo $dec_dd."<br>";
17
18$hex_cc = "cc";
19$dec_cc = hexdec($hex_cc);
20echo $hex_cc." -> ";
21echo $dec_cc."<br>";
22
23$hex_bb = "bb";
24$dec_bb = hexdec($hex_bb);
25echo $hex_bb." -> ";
26echo $dec_bb."<br>";
27
28$hex_aa = "aa";
29$dec_aa = hexdec($hex_aa);
30echo $hex_aa." -> ";
31echo $dec_aa."<br>";
32
33$hex_99 = "99";
34$dec_99 = hexdec($hex_99);
35echo $hex_99." -> ";
36echo $dec_99."<br>";
37
38$hex_88 = "88";
39$dec_88 = hexdec($hex_88);
40echo $hex_88." -> ";
41echo $dec_88."<br>";
42
43$hex_77 = "77";
44$dec_77 = hexdec($hex_77);
45echo $hex_77." -> ";
46echo $dec_77."<br>";
47
48$hex_66 = "66";
49$dec_66 = hexdec($hex_66);
50echo $hex_66." -> ";
51echo $dec_66."<br>";
52
53$hex_55 = "55";
54$dec_55 = hexdec($hex_55);
55echo $hex_55." -> ";
56echo $dec_55."<br>";
57
58$hex_44 = "44";
59$dec_44 = hexdec($hex_44);
60echo $hex_44." -> ";
61echo $dec_44."<br>";
62
63$hex_33 = "33";
64$dec_33 = hexdec($hex_33);
65echo $hex_33." -> ";
66echo $dec_33."<br>";
67
68$hex_22 = "22";
69$dec_22 = hexdec($hex_22);
70echo $hex_22." -> ";
71echo $dec_22."<br>";
72
73$hex_11 = "11";
74$dec_11 = hexdec($hex_11);
75echo $hex_11." -> ";
76echo $dec_11."<br>";
77
78$hex_0 = "0";
79$dec_0 = hexdec($hex_0);
80echo $hex_0." -> ";
81echo $dec_0."<br>";
82?>

Ausgabe des Skripts:

ff -> 255
ee -> 238
dd -> 221
cc -> 204
bb -> 187
aa -> 170
99 -> 153
88 -> 136
77 -> 119
66 -> 102
55 -> 85
44 -> 68
33 -> 51
22 -> 34
11 -> 17
0 -> 0