3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $html = <<<HTML <html lang="sk"><head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250"> <meta http-equiv="Expires" content="now"> <meta http-equiv="pragma" content="no-cache"> <meta name="language" content="sk"> <meta name="description" content="Sortiment. Prezrite si našu ponuku. Máme 10 000 typov tovarov na sklade, ďalších 200 000 tovarov na objednávku. Tovar dodáme už nasledujúci pracovný deň zo skladu v Košiciach. Doručovanie pomocou UPS alebo Slovenskej pošty. SOS electronic europe - súčiastky z overených zdrojov."> <meta name="keywords" content="Sortiment, "> <meta name="robots" content="index, follow"> <meta property="fb:admins" content="100001090280781"> <title>Sortiment | SOS electronic</title> </head> <body onload=""> <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-TPJZ5N" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager --> <div id="container"> <div id="flags"> <ul> <li>SK </li> <li><a>/ </a><a href="http://www.soselectronic.cz/?str=12" title="česky">CZ</a></li> <li><a>/ </a><a href="http://www.soselectronic.hu/?str=12" title="magyarul">HU</a></li> <li><a>/ </a><a href="http://www.soselectronic.com/?str=12" title="english">EN</a></li> <li><a>/ </a><a href="http://www.soselectronic.de/?str=12" title="deutsch">DE</a></li> <li><a>/ </a><a href="http://www.soselectronic.ro/?str=12" title="română">RO</a></li> <li><a>/ </a><a href="http://www.soselectronic.pl/?str=12" title="polski">PL</a></li> </ul> </div> <a name="zaciatok"></a> <div id="logo_base"> <div id="logo"> <a href="//www.sos.sk/"><img src="//www.sos.sk/images/sos_logo_sk.gif" alt="SOS electronic logo"></a> <div id="searchform_main"> <form name="SearchWWW" action="//www.sos.sk/?str=12" method="get" target="_top"> <input name="str" value="12" type="hidden"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tbody><tr><td> <input name="searchstring" id="searchstring" onclick="select_searchstring();" value="Vyhľadávanie súčiastok" type="text"> </td><td width="30"> <input value="" class="submitform" type="submit"> </td></tr></tbody></table> </form> </div> <img id="electroniconline" src="//www.sos.sk/images/electroniconline.png" alt="OnLine Shop image"> </div> <div id="login_area"> <table> <tbody><tr><td valign="top"> <form id="login_form" action="//www.sos.sk/cgi-bin/sos_online.pl" method="POST" target="_top"> <input name="Ctrl" value="login" type="hidden"> <input name="Lng" value="sk" type="hidden"> <input name="url_link" value="cgi-bin/sos_online.pl" type="hidden"> <input name="name" id="logname" value="Číslo" onfocus="value='';" type="text"> <input name="passwd" id="logpwd" value="Heslo" onfocus="value=''; this.setAttribute('type','password');" type="password"> <div> <span>Zostať prihlásený</span> <input name="stay_logged" type="checkbox"> </div> <input value="Vstúpiť" type="submit"> </form> </td> <td valign="top"> <a href="//www.sos.sk/?str=651"> <div id="shopcart"> <img src="//www.sos.sk/images/cart.png"> <br> Nákupný košík [<div id="uppermenu_basket_count">0</div>] </div> </a> </td></tr></tbody></table> </div> </div> <!-- HORIZONTALNE MENU--> <div id="horne_menu_base"> <table width="100%" cellpadding="0" cellspacing="0"> <tbody><tr><td> <div id="horne_menu"> <ul id="nav" class="drop"> <li><a href="//www.sos.sk/">Domov</a></li> <li><a href="//www.sos.sk/?str=96">Linecard</a></li> <!-- ----------- Katalóg, produkty -------------------------- --> <li><a onclick="show_main_menu();">Produkty</a> <ul> <li><a href="//www.sos.sk/?str=12">Sortiment</a></li> <!-- <li><a href="http://solutions.sos.sk/">Riešenia</a></li>--> <li><a href="//www.sos.sk/?str=96">Linecard</a></li> <!-- <li><a href="//www.sos.sk/?str=1">Produktové novinky</a></li> --> <li><a href="//www.sos.sk/?str=968">SOS cinema - videá</a></li> <!-- <li><a href="//www.sos.sk/?str=1">Technická podpora</a></li> --> <li><a href="//www.sos.sk/?str=374">Novinky na sklade</a></li> </ul> </li> <!-- ----------- Nakupovanie -------------------------- --> <li><a onclick="show_main_menu();">Nakupovanie</a> <ul> <li><a href="//www.sos.sk/?str=19">Online Shop</a></li> <li><a href="//www.sos.sk/?str=834">Ako objednať</a></li> <li><a href="//www.sos.sk/?str=592">Ako sa vybavuje objednávka</a></li> <li><a href="//www.sos.sk/?str=251">Dodacie a platobné obchodné podmienky</a> <ul> <li><a href="//www.sos.sk/?str=251#payment">Spôsob platby</a></li> <li><a href="//www.sos.sk/?str=642">Poplatky/Dopravné</a></li> </ul> </li> <li><a href="//www.sos.sk/?str=603">Reklamácie</a> <ul> <li><a href="//www.sos.sk/?str=603">Reklamačný formulár</a></li> <li><a href="//www.sos.sk/pdf/rekl_por_2009_po.pdf">Reklamačné podmienky pre právnické osoby</a></li> <li><a href="//www.sos.sk/pdf/rekl_por_2009_fo.pdf">Reklamačné podmienky pre fyzické osoby</a></li> </ul> </li> <li><a href="//www.sos.sk/?str=1112">Vernostný program PREMIUM</a></li> <li><a href="//www.sos.sk/?str=294">Akcie</a></li> <li><a href="//www.sos.sk/?str=28">Výpredaj</a></li> <li><a href="//www.sos.sk/?str=23">FAQ</a></li> </ul> </li> <!-- ----------- Aktuality -------------------------- --> <li><a onclick="show_main_menu();">Aktuality</a> <ul> <!--<li><a href="//www.sos.sk/?str=1230">Produktové články</a></li> --> <!--<li><a href="//www.sos.sk/?str=96">Podľa linecardu</a></li> --> <li><a href="//www.sos.sk/?str=1230&amp;p=SOS electronic">PR články</a></li> <li><a href="//www.sos.sk/?str=968&amp;code=newest">SOS cinema - najnovšie videá</a></li> <li><a href="//www.sos.sk/?str=257">Newsletter</a></li> <li><a href="//www.sos.sk/?str=374">Novinky na sklade </a></li> </ul> </li> <!-- ----------- Podpora navyše -------------------------- --> <li><a onclick="show_main_menu();">Podpora navyše</a> <ul> <!-- <li><a href="//www.sos.sk/?str=1">Technická podpora</a></li> --> <li><a href="//www.sos.sk/?str=968">SOS cinema - videá</a></li> <!-- <li><a href="//www.sos.sk/?str=1">SOS news</a></li> --> <li><a href="//www.sos.sk/?str=1112">Vernostný program PREMIUM</a></li> <!-- <li><a href="//www.sos.sk/?str=1">Propagácia pre Vaše výrobky</a></li> --> <li><a href="//www.sos.sk/?str=21">Download</a></li> <li><a href="//www.sos.sk/?str=1022">Vzorky zdarma</a></li> <!-- <li><a href="//www.sos.sk/?str=1">Tématické súťaže</a></li> --> <li><a href="//www.sos.sk/?str=1104">Pizza workshopy</a></li> <li><a href="//www.sos.sk/?str=1297">SOS webináre</a></li> </ul> </li> <!-- <li><a href="//www.sos.sk/?str=1">Technická podpora</a></li> --> <!-- <li><a HREF="//www.sos.sk/?str=96">linecard</a></li> --> <!-- <li><a HREF="//www.sos.sk/?str=374">novinky</a></li> --> <li><a href="//www.sos.sk/?str=19">Online shop</a></li> <li><a href="//www.sos.sk/?str=24">Kontakty</a></li> <li><a href="//www.sos.sk/?str=877">Kariéra</a></li> <!-- ----------- O nás -------------------------- --> <li><a onclick="show_main_menu();">O nás</a> <ul> <li><a href="//www.sos.sk/?str=1026">Firemný profil</a></li> <li><a href="//www.sos.sk/?str=24">Kontakty</a></li> <li><a href="//www.sos.sk/?str=874">Kariéra</a></li> <li><a href="http://fond.sos.sk" target="_blank">Fond SOS</a></li> <!-- <li><a href="//www.sos.sk/?str=1022">Firemné údaje</a></li> --> <!-- <li><a href="//www.sos.sk/?str=1230&p=SOS electronic">PR správy</a></li> --> <!-- <li><a href="//www.sos.sk/?str=1022">Dianie vo vnútri</a></li> --> </ul> </li> <li><a href="http://www.ecubeportal.com/sk/?utm_medium=websos&amp;utm_source=menu&amp;utm_campaign=sos_titulka" target="_blank">eCube</a></li> </ul> <img src="//www.sos.sk/images/menu_bckg_right.png" align="right"> </div> </td><td id="login_links"> <div> <a href="//www.sos.sk/?str=198">Zabudol som heslo</a> <br><a href="//www.sos.sk/?str=197">Chcem sa zaregistrovať</a> </div> <div id="kosiky"> <div><a href="//www.sos.sk/?str=583&amp;subaction=view">Žiadosť o cenovú ponuku [0]</a></div> <div><a href="//www.sos.sk/?str=583&amp;subaction=view"><img src="//www.sos.sk/images/request.png"></a></div> </div> </td></tr></tbody></table> </div> <div id="out_of_eu_restriction_big">This product is available for countries <br>within the European Union only.</div> <div id="delay_reviewing_big">Ospravedlňujeme sa za <b>zmeškaný termín</b>. Náhradný termín preverujeme u dodávateľa a zaktualizujeme ho hneď po jeho získaní. Ďakujeme.</div> <div id="social_links" "=""> <a href="//www.sos.sk/?str=1202&amp;url=/?str=12" class="fancybox_iframe">Nahlásiť chybu</a> </div> <div id="mainspace"> <div id="main_area_whole"> <!-- article begin --> <h1>Sortiment</h1> <div id="ajax_message"></div> <div id="ajax-loading"><img src="//www.sos.sk/images/ajax-loader.gif" align="left" hspace="20">Loading ...</div> <div id="param-section"> <div class="param-block" id="prodgroups_selection_block"> <ul> <li> <a href="//www.sos.sk/pasivne-suciastky" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/A.jpg"></div>Pasívne súčiastky</a> </li> <li> <a href="//www.sos.sk/diskretne-polovodice" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/B.jpg"></div>Diskrétne polovodiče</a> </li> <li> <a href="//www.sos.sk/integrovane-obvody" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/C.jpg"></div>Integrované obvody</a> </li> <li> <a href="//www.sos.sk/moduly-komunikacne-a-napajacie" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/D.jpg"></div>Moduly komunikačné a napájacie</a> </li> <li> <a href="//www.sos.sk/optoelektronicke-a-zobrazovacie-prvky" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/E.jpg"></div>Optoelektronické a zobrazovacie prvky</a> </li> <li> <a href="//www.sos.sk/konektory-a-svorkovnice" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/F.jpg"></div>Konektory a svorkovnice</a> </li> <li> <a href="//www.sos.sk/kable-snury-a-laboratorny-program" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/G.jpg"></div>Káble, šnúry a laboratórny program</a> </li> <li> <a href="//www.sos.sk/prepinace-tlacidla-rele-a-poistky" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/H.jpg"></div>Prepínače,tlačidlá,relé a poistky</a> </li> <li> <a href="//www.sos.sk/ventilatory-a-chladice" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/I.jpg"></div>Ventilátory a chladiče</a> </li> <li> <a href="//www.sos.sk/krabicky-a-montazny-material" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/J.jpg"></div>Krabičky a montážny materiál</a> </li> <li> <a href="//www.sos.sk/nastroje" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/K.jpg"></div>Nástroje</a> </li> <li> <a href="//www.sos.sk/spajkovacia-technika" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/L.jpg"></div>Spájkovacia technika</a> </li> <li> <a href="//www.sos.sk/spajky-chemia-dps" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/M.jpg"></div>Spájky,chémia,DPS</a> </li> <li> <a href="//www.sos.sk/meracie-pristroje" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/N.jpg"></div>Meracie prístroje</a> </li> <li> <a href="//www.sos.sk/akumulatory-adaptery-zdroje" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/O.jpg"></div>Akumulátory, adaptéry, zdroje</a> </li> <li> <a href="//www.sos.sk/katalogy-knihy-cd-romy" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/Q.jpg"></div>Katalógy, knihy, CD- ROMy</a> </li> <li> <a href="//www.sos.sk/elektroakusticke-prvky" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/R.jpg"></div>Elektroakustické prvky</a> </li> <li> <a href="//www.sos.sk/priemyselna-automatizacia" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/S.jpg"></div>Priemyselná automatizácia</a> </li> <li> <a href="//www.sos.sk/domaca-technika" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/T.jpg"></div>Domáca technika</a> </li> <li> <a href="//www.sos.sk/prakticka-elektronika" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/U.jpg"></div>Praktická elektronika</a> </li> <li> <a href="//www.sos.sk/embedded-systemy" onclick="javascript: show_loading();"><div class="produgroups_selection_block_img"><img src="//www.sos.sk/a_info/img_tree/V.jpg"></div>Embedded systémy</a> </li> </ul> </div> </div> <br> <br> </div> <!--koniec sekcie main_area--> </div> <!--koniec sekcie mainspace--> <div id="footer"> <div id="menu_down"> <div><a href="https://www.facebook.com/soselectronic.sk" target="_blank"><img src="//www.sos.sk/images/facebook_transp.png"></a></div> <ul> <li><a href="#zaciatok">Hore</a></li> <li><a href="//www.sos.sk/">Hlavná stránka</a></li> <li><a href="//www.sos.sk/?str=21">Download</a></li> <!--<li><a href="//www.sos.sk/?str=56">Archív</a></li>--> <li><a href="//www.sos.sk/?str=251#payment">Spôsob platby</a></li> <li><a href="//www.sos.sk/?str=251">Obch.podmienky</a></li> <li><a href="//www.sos.sk/?str=603">Reklamácie</a></li> <li><a href="//www.sos.sk/?str=23">FAQ</a></li> <li><a href="//www.sos.sk/?str=1026">Profil firmy</a></li> <li><a href="//www.sos.sk/?str=24">Kontakty</a></li> <li><a href="//www.sos.sk/?str=11">Zamestnanie</a></li> <li><a href="//www.sos.sk/?str=1498">Cookies</a></li> </ul> </div> <div id="copyright"> <p>© SOS electronic s.r.o.<br>1991-2015</p> </div> </div> <!--koniec sekcie footer--> </div> <div> <form method="post" name="cookie_agree" action="?str=1531"> Súbory cookie nám pomáhajú poskytovať služby. Používaním našich služieb vyjadrujete súhlas s používaním súborov cookie. <a href="?str=1498">Ďalšie informácie</a> <input value="OK, súhlasím" type="submit"> </form> </div> <div id="fancybox-tmp"></div><div id="fancybox-loading"><div></div></div><div id="fancybox-overlay"></div><div id="fancybox-wrap"><div id="fancybox-outer"><div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div><div id="fancybox-content"></div><a id="fancybox-close"></a><div id="fancybox-title"></div><a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a><a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a></div></div></body></html> HTML; function try_dom_load_html($html) { $oldUseErrorsValue = libxml_use_internal_errors(true); libxml_clear_errors(); $dom = new \DOMDocument; $dom->loadHTML($html); $errors = libxml_get_errors(); libxml_clear_errors(); libxml_use_internal_errors($oldUseErrorsValue); foreach ($errors as $error) { if ($error->code === 6003) { // "input conversion failed due to input error ..." foreach ((new DOMXPath($dom))->query("./head/meta", $dom->documentElement) as $metaNode) { $isContentType = $haveContent = false; $content = null; foreach ($metaNode->attributes as $attribute) { if (strtolower($attribute->name) === 'http-equiv' && strtolower($attribute->value) === 'content-type') { $isContentType = true; if ($haveContent) { break; } } else if (strtolower($attribute->name) === 'content') { $content = $attribute->value; if ($isContentType) { break; } else { $haveContent = true; } } } if (!$isContentType) { continue; } if (!preg_match('/\bcharset\s*=\s*([\'"]?)(\S+?)\1/', $content, $match)) { throw new \Exception('Unable to determine character set from <meta> tag'); } $charset = $match[2]; var_dump($charset); $oldUseErrorsValue = libxml_use_internal_errors(true); libxml_clear_errors(); $dom = new DOMDocument; $dom->loadHTML(iconv($charset, $charset . '//IGNORE', $html)); libxml_clear_errors(); libxml_use_internal_errors($oldUseErrorsValue); return $dom; } throw new \Exception('Unable to load document or determine target character set'); } } return $dom; } $dom = try_dom_load_html($html); var_dump($dom->saveHTML());
based on bqQcR
Output for 5.4.0 - 5.5.34, 5.6.0 - 5.6.20, 5.6.28 - 7.0.5, 7.0.20 - 7.2.0
string(1) "w" Notice: iconv(): Wrong charset, conversion from `w' to `w//IGNORE' is not allowed in /in/H3MUI on line 476 Warning: DOMDocument::loadHTML(): Empty string supplied as input in /in/H3MUI on line 476 string(1) " "
Output for 7.0.6 - 7.0.10
string(1) "w" Fatal error: Uncaught Error: Call to undefined function iconv() in /in/H3MUI:476 Stack trace: #0 /in/H3MUI(491): try_dom_load_html('<html lang="sk"...') #1 {main} thrown in /in/H3MUI on line 476
Process exited with code 255.
Output for 5.5.35 - 5.5.38, 5.6.21 - 5.6.25
string(1) "w" Fatal error: Call to undefined function iconv() in /in/H3MUI on line 476
Process exited with code 255.