{"id":548,"date":"2011-03-20T22:07:12","date_gmt":"2011-03-20T21:07:12","guid":{"rendered":"https:\/\/d-mueller.de\/blog\/?p=548"},"modified":"2016-01-11T23:32:27","modified_gmt":"2016-01-11T22:32:27","slug":"php-wtf-6","status":"publish","type":"post","link":"https:\/\/d-mueller.de\/blog\/php-wtf-6\/","title":{"rendered":"PHP WTF #6"},"content":{"rendered":"<p>Heute inkrementieren wir mal Strings.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n$string = &#039;Iteration number 0&#039;;\r\n\r\n$i = 10;\r\n\r\nwhile ($i--)\r\n\techo $string++ . &quot;&lt;br \/&gt;&quot;;\r\n<\/pre>\n<p><b>Output:<\/b><\/p>\n<pre data-enlighter-language=\"enlighter\" class=\"EnlighterJSRAW\">\r\nIteration number 0\r\nIteration number 1\r\nIteration number 2\r\nIteration number 3\r\nIteration number 4\r\nIteration number 5\r\nIteration number 6\r\nIteration number 7\r\nIteration number 8\r\nIteration number 9\r\n<\/pre>\n<p>Das war ja schonmal ganz nett zum warmwerden. Aber jetzt: fasten your seatbelts.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\nfor ($i = &#039;a&#039;; $i &lt;= &#039;z&#039;; $i++) \r\n{\r\n\techo $i . &quot; &quot;;\r\n}\r\n<\/pre>\n<p><b>Output:<\/b><\/p>\n<pre data-enlighter-language=\"enlighter\" class=\"EnlighterJSRAW\">\r\na b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz ea eb ec ed ee ef eg eh ei ej ek el em en eo ep eq er es et eu ev ew ex ey ez fa fb fc fd fe ff fg fh fi fj fk fl fm fn fo fp fq fr fs ft fu fv fw fx fy fz ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp gq gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg hh hi hj hk hl hm hn ho hp hq hr hs ht hu hv hw hx hy hz ia ib ic id ie if ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx jy jz ka kb kc kd ke kf kg kh ki kj kk kl km kn ko kp kq kr ks kt ku kv kw kx ky kz la lb lc ld le lf lg lh li lj lk ll lm ln lo lp lq lr ls lt lu lv lw lx ly lz ma mb mc md me mf mg mh mi mj mk ml mm mn mo mp mq mr ms mt mu mv mw mx my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt nu nv nw nx ny nz oa ob oc od oe of og oh oi oj ok ol om on oo op oq or os ot ou ov ow ox oy oz pa pb pc pd pe pf pg ph pi pj pk pl pm pn po pp pq pr ps pt pu pv pw px py pz qa qb qc qd qe qf qg qh qi qj qk ql qm qn qo qp qq qr qs qt qu qv qw qx qy qz ra rb rc rd re rf rg rh ri rj rk rl rm rn ro rp rq rr rs rt ru rv rw rx ry rz sa sb sc sd se sf sg sh si sj sk sl sm sn so sp sq sr ss st su sv sw sx sy sz ta tb tc td te tf tg th ti tj tk tl tm tn to tp tq tr ts tt tu tv tw tx ty tz ua ub uc ud ue uf ug uh ui uj uk ul um un uo up uq ur us ut uu uv uw ux uy uz va vb vc vd ve vf vg vh vi vj vk vl vm vn vo vp vq vr vs vt vu vv vw vx vy vz wa wb wc wd we wf wg wh wi wj wk wl wm wn wo wp wq wr ws wt wu wv ww wx wy wz xa xb xc xd xe xf xg xh xi xj xk xl xm xn xo xp xq xr xs xt xu xv xw xx xy xz ya yb yc yd ye yf yg yh yi yj yk yl ym yn yo yp yq yr ys yt yu yv yw yx yy yz\r\n<\/pre>\n<p>Wow! Und allemal cooler als der hier:<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\nfor ($i = ord(&#039;a&#039;); $i &lt;= ord(&#039;z&#039;); $i++) \r\n{\r\n\techo chr($i) . &quot; &quot;;\r\n}\r\n<\/pre>\n<p><b>Output:<\/b><\/p>\n<pre data-enlighter-language=\"enlighter\" class=\"EnlighterJSRAW\">\r\na b c d e f g h i j k l m n o p q r s t u v w x y z\r\n<\/pre>\n<p>Wem langweilig ist, kann damit gern ein bisschen rumspielen (<a href=\"http:\/\/www.asciitable.com\/\">ASCII-Tabelle gef\u00e4llig?<\/a>). Siehe dazu auch den <a href=\"http:\/\/www.php.net\/manual\/en\/language.operators.increment.php\">Manual-Eintrag bei php.net<\/a>:<\/p>\n<blockquote><p>\nPHP follows Perl&#8217;s convention when dealing with arithmetic operations on character variables and not C&#8217;s. For example, in Perl &#8218;Z&#8217;+1 turns into &#8218;AA&#8216;, while in C &#8218;Z&#8217;+1 turns into &#8218;[&#8218; ( ord(&#8218;Z&#8216;) == 90, ord(&#8218;[&#8218;) == 91 ). Note that character variables can be incremented but not decremented and even so only plain ASCII characters (a-z and A-Z) are supported.\n<\/p><\/blockquote>\n<p>Ach ja, auch wenns \u00fcberhaupt nicht zum Thema passt: Wusstet ihr, dass man f\u00fcr den <b>Ungleich<\/b>-Operator <i>!=<\/i> auch im Visual Basic-Style <i>&lt;&gt;<\/i> schreiben kann?<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\nvar_dump(&quot;123&quot; &lt;&gt; 123); \/\/bool(false)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Heute inkrementieren wir mal Strings. $string = &#039;Iteration number 0&#039;; $i = 10; while ($i&#8211;) echo $string++ . &quot;&lt;br \/&gt;&quot;; Output: Iteration number 0 Iteration number 1 Iteration number 2 Iteration number 3 Iteration number 4 Iteration number 5 Iteration &hellip; <a href=\"https:\/\/d-mueller.de\/blog\/php-wtf-6\/\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,14,3],"tags":[],"class_list":["post-548","post","type-post","status-publish","format-standard","hentry","category-php","category-php-wtf","category-webdev"],"_links":{"self":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/comments?post=548"}],"version-history":[{"count":0,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/posts\/548\/revisions"}],"wp:attachment":[{"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/media?parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/categories?post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/d-mueller.de\/blog\/wp-json\/wp\/v2\/tags?post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}