Home
About
Search
🌐
English Română
  • Unknown runtime error – Internet Explorer with InnerHTML – another meaningful error

    Citește postarea în română

    Jun 6, 2010 Internet Explorer JavaScript
    Share on:

    I was working the other day on a new JavaScript game for the games section. Like the majority of the developers (like the statistics show) I’m using FireFox for developing. But as the game reached the testing faze it was time to see if it was working properly in Internet Explorer.

    To test in Internet Explorer is a real pleasure, basically you see an error and then you hope that you’ll find the source.

    Of course there was an error, one full of meaning as usual:

    Unknown runtime error??? WTF??? If he does not know how should I?

    The piece of code that was generating the error was:

    1canvas.innerHTML = '';
    

    Where canvas was a variable which was storing an document.getElementById(‘canvas’), and the id canvas was from:

    1<table border="0" cellspacing="0" cellpadding="0">
    2<tbody id="canvas"></tbody>
    3</table>
    

    Looks wrong? well is not because at that point I was testing other games which are using the same thing with no trouble, even in IE.

    I’ve tried it in IE 6, of course with the same result.

    It looks like this error appears on elements like table, tbody, p and others.

    To finally fix the issue I used instead of a tbody, a div tag in which I’m adding the elements and the issue was gone.

    What is interesting is that this issue does not always appear for a specific tag!

    Thank you Microsoft for this meaningful error messages that are so full of logic!

  • PHP type hinting for scalar data types, a step closer

    Citește postarea în română

    May 22, 2010
    Share on:

    In PHP 5 a new concept was introduced, type hinting. This feature allows validation of a parameter for a certain type.

    This validation type is very popular in object orientated languages and I believe it represents a plus for the PHP object model and even more for his dynamic nature it self.

    In PHP 5.1 validation for the array data type was added.

    Let’s take a small example:

     1class a { }
     2
     3class b { }
     4
     5function testa (a $a) {
     6    echo "Bla bla\n";
     7}
     8
     9testa(new a());
    10
    11testa(new b());
    

    The result is:

    1Bla bla
    2
    3Fatal error: Argument 1 passed to testa() must be an instance of a, called in ...
    

    Cool, ha?

    The type in which we can validate can be a class, an abstract class or even an interface which is inherited  by other classes, like:

     1interface inherited { }
     2
     3class a implements inherited { }
     4
     5class b implements inherited { }
     6
     7function testa (inherited $a) {
     8    echo "Bla bla\n";
     9}
    10
    11testa(new a());
    12
    13testa(new b());
    

    And the above example will not raise any errors.

    Unfortunately there is no way to validate primary (or scalar) data types. When PHP 5.3 was being released there have been some discussions on the subject, but it seems that it was too late, and the patch did not make it to the final version.

    Yesterday, while I was doing my morning reading at a cup of coffee, what do I see on Ilia Alshanetsky blog: Scalar Type Hints are Here! Well, is a little exaggerated, there are not exactly here but there really close. Basically there are in the SVN trunk and will be available in the next stable version!

    Of course that even in the current version of type hinting is not exactly mandatory to use it in PHP, is more of an issue of fine tune.

    Basically we could already validate to a certain primary data type, but still:

    1function testint($var) {
    2     if(!is_int($var)) {
    3         trigger_error("Type must be Integer", E_USER_ERROR);
    4     }
    5     .......
    6}
    

    is not exactly as elegant as:

    1function testint(int $var) {
    2     ......
    3}
    
  • CodeIgniter 1.7 Professional Development Packt Publishing – Book review part 1

    Citește postarea în română

    May 11, 2010 CodeIgniter PHP
    Share on:

    0905.jpg

    Packt Publishing has published a new book on the RAD PHP framework CodeIgniter version 1.7. The book CodeIgniter 1.7 Professional Development written by Adam Griffiths, has the slogan “become CodeIgniter experts with professional tools, techniques and extended libraries”.

    Just from the slogan you can see a slightly different tone then the book CodeIgniter 1.7 from Packt Publishing, which in my opinion has the purpose of showing what the CodeIgniter framework can do.

    This book has the purpose of showing how can you develop professional applications, or at least until proven otherwise, stay tuned to find out!

    An argument for the slogan is the target audience like is defined in the “Who this book is written for” section, which contains the phrase:

    Basic knowledge of CodeIgniter will be helpful.

    A dangerous phrase in my opinion, because it can scare off a beginner, even though in the book it looks like all the steps are described starting from server installation.

    If from the first book I was expecting a general presentation of the framework, now I’m curios to see if the examples are more ample and more concrete.

    From the sample chapter it looks like there is a lot of code. As long as it is logical I thing it’s a good thing, a lot of times is easier to understand code, which you will after all write and you can take as an example, then theory.

    But more about this book after I’ll get to read it.

    To be continued…

  • PHP as a general-purpose language

    Citește postarea în română

    May 8, 2010 CLI PHP PHP-GTK Winbinder
    Share on:

    PHP for desktop, is it worth it?

    PHP is described on Wikipedia as:

    PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages.

    Taking this into consideration, apps divide in 3 category: web, command line and desktop.

    For the Web, PHP is the most popular open-source (and not only) programming language.

    PHP CLI

    PHP CLI (Command Line Interface) I find it very interesting, even though is not used at it’s full potential. A lot of developers prefer shell scripting or Perl with no real reason. I’ve been playing around with this tool and I liked the result.

    Important frameworks like: Zend, Symfony or Cake PHP are using PHP CLI to generate projects, models, CRUD or other features that can be easily used with a command line.

    In the Windows environment the command line is not exactly popular, but in Linux is almost imperative. After all what’s the point of using shell scripting when you can use a powerful language with a lot of features like PHP?

    But CLI is not limited just to the command line, it is usually used for cronjobs, pipes, socket-servers etc.

    PHP-GTK

    When it comes to PHP and desktop usually people thing about PHP-GTK. What do I thing about the project? Is not dead, like it says on the official website, but is not exactly alive. The reason? Gtk is not exactly simple. If you come from the Linux environment probably is not that difficult, but if you usually work on the web is not exactly html… Nevertheless there is a community that keep this project alive.

    Nevertheless, it allows developers to build desktop apps in PHP, compatible with a wide variety of operating systems.

    But there is an issue, the resulting apps are not exactly compiled code, they must run using a PHP virtual machine. Here is the issue, how do you distribute the app? If you have a small app of only few lines of code, to distribute it with a virtual machine is a little complicated… Also the code is visible, of course there are methods to solve this issue, but there aren’t exactly simple.

    This is probabily the most popular PHP platform for desktop, if you can say that about this environment.

    The documentation is pretty big, it was taken from the C++ version. Is not as well polished like the PHP manual for instance, but I believe is sufficient.

    Winbinder

    Compared to PHP-GTK it has an disadvantage, it only works on MS Widows operating system. The advantage is that it has a much simpler API. If I had to choose a PHP platform for desktop, probably I would go for Winbinder. Unfortunately is in the same state, is not dead but is not exactly alive. It also have the support of a community, but without any particular special results.

    The issue with the compiled code is found here also, and even more the issue with platform distribution is just as bad. I firmly believe that if you want to develop an app using this platform, to make it work on your computer is the easiest part, to make it work on someone else’s computer is the real issue…

    The documentation is pretty small, because of the API. But simplicity is good when it comes to programming, that means you can easily build pretty interesting apps.

    Compilers

    There a few, and the majority of them have some issue because they use old PHP versions of even old GTK. I’ve spend many hours on Google trying to find some reals solution but with no success.

    Most popular compilers:

    • Bambalam – works well with CLI and Winbinder. But it has a great disadvantage: it’s only compatible with PHP 4.4.4, and I believe that says it all. Anyway I believe it was the most interesting solution, unfortunately to old (the last version was released in 2006).
    • PriadoBlender – works well with PHP-GTK and CLI, but is not very stable. The last (beta) version was released in 2007, and since then nothing new was ever heard from it. Probably if that version would be updated  it would help a lot the PHP-GTK project.

    Conclusion

    When it comes to Web, everything is great!

    PHP as a command line tool is ever more popular and more tools appear each day!

    In the desktop environment is a “the living dead” sensation… This projects are not dead but there not exactly alive. Of course there are other solution for PHP on desktop which I did not mention, but there are in about the same state. Probably a new approach would help, something more attractive for web developers and those passionate about this language.

  • Web as a platform on Desktop using Adobe AIR

    Citește postarea în română

    Apr 21, 2010 Adobe AIR JavaScript SQLite
    Share on:

    After my second little project, I’m back with my opinion on Adobe AIR!

    Working with Adobe AIR I had a revelation, in 2004 John Battelle and Tim O’Reilly presented the concept “Web as Platform”. These days, using the Web as a platform we can develop desktop applications. Basically we’ve left an environment to come back to it with a new perspective.

    If the first time I had only 3 days at my disposal, this time I wasn’t constrained. During this time I had the opportunity to discover some of the features, like NativeMenu and the support for SQLite.

    I believe that SQLite has the purpose of compensating for the storing possibility that are not available on this platform, like cookies. Of course, SQLite is using a database, and the storing is way superior to the traditional Web.

    But way choose Adobe AIR compared to other platforms like Java or C#? Because it is simple! I don’t believe that Adobe AIR was intended to be a tool for developing large applications, even though only time will tell if that’s possible. This is a great tool for small to medium scale apps, which  can bring something extra to the Web. For instance in my app I had an alert system, I thought what I would like next to what I already have on the Web. With this alerts I don’t have to check all the time what’s new. Just as well I believe features like chats can be implemented or similarly features, after all if it can be done on the Web, it can be done here.

    What Adobe AIR has is a very interesting distribution system, basically the platform is distributed with Adobe Acrobat Reader, thing that can make it available even on your computer without even knowing.

    What Adobe AIR does not have, and I thing it would be useful, is a system for accessing COM objects for instance, possibility to access different database systems different then SQLite, which is quite simple.

    Another feature that I would like is the possibility to access Adobe Flesh features from JavaScript. I know, I should use Flash if there are Flash features, but I prefer JavaScript as a platform. Probably the reason this features are not available in JavaScript is because this language has the HTML 5 features, like: Canvas and Audio, which somehow compensate with Flash features that are not available in JavaScript by default.

    Adobe AIR 2 which is in beta version for the moment, will probably solve some of the need to access the system resources.

    In my opinion, Adobe AIR is the platform on which a Web developer can develop desktop apps with ease!

    • ««
    • «
    • 12
    • 13
    • 14
    • 15
    • 16
    • »
    • »»

Claudiu Perșoiu

Programming, technology and more
Read More

Recent Posts

  • Adding a slider to Tasmota using BerryScript
  • The future proof project
  • Docker inside wsl2
  • Moving away from Wordpress
  • Custom path for Composer cache
  • Magento2 and the ugly truth
  • A bit of PHP, Go, FFI and holiday spirit
  • How to make use of the Xiaomi Air Conditioning Companion in Home Assistant in only 20 easy steps!

PHP 49 MISCELLANEOUS 46 JAVASCRIPT 14 MAGENTO 7 MYSQL 7 BROWSERS 6 DESIGN PATTERNS 5 HOME AUTOMATION 2 LINUX-UNIX 2 WEB STUFF 2 GO 1

PHP 35 JAVASCRIPT 15 PHP5.3 11 MAGENTO 7 PHP6 7 MYSQL 6 PHP5.4 6 ZCE 6 CERTIFICARE 5 CERTIFICATION 5 CLOSURES 4 DESIGN PATTERNS 4 HACK 4 ANDROID 3
All tags
3D1 ADOBE AIR2 ANDROID3 ANGULAR1 ANONYMOUS FUNCTIONS3 BERRYSCRIPT1 BOOK1 BROWSER2 CARTE1 CERTIFICARE5 CERTIFICATION5 CERTIFIED1 CERTIFIED DEVELOPER1 CHALLENGE1 CHM1 CLASS1 CLI2 CLOSURES4 CODE QUALITY1 CODEIGNITER3 COFFEESCRIPT1 COLLECTIONS1 COMPOSER1 CSS1 DEBUG1 DESIGN PATTERNS4 DEVELOPER1 DEVELOPMENT TIME1 DOCKER2 DOCKER-COMPOSE1 DOUGLAS CROCKFORD2 ELEPHPANT2 FACEBOOK2 FFI1 FINALLY1 FIREFOX3 GAMES1 GENERATOR1 GO1 GOOGLE1 GOOGLE CHROME1 GOOGLE MAPS1 HACK4 HOMEASSISTANT2 HTML2 HTML HELP WORKSHOP1 HTML51 HUG1 HUGO1 INFORMATION_SCHEMA1 INI1 INTERNET EXPLORER3 IPV41 IPV61 ITERATOR2 JAVASCRIPT15 JQUERY1 LAMBDA1 LINUX1 MAGENTO7 MAGENTO22 MAP1 MINESWEEPER1 MOTIVATION1 MYSQL6 NGINX1 NODE.JS2 NOSQL1 OBSERVER3 OBSERVER PATTERN1 OOP1 OPERA1 OPTIMIZATION1 ORACLE1 PAGESPEED1 PAIR1 PARSE_INI_FILE1 PHONEGAP2 PHP35 PHP ELEPHANT2 PHP FOR ANDROID1 PHP-GTK1 PHP42 PHP53 PHP5.311 PHP5.46 PHP5.53 PHP5.61 PHP67 PHP7.41 PROGRAMMING1 REVIEW1 ROMANIAN STEMMER2 SAFARY1 SCALAR TYPE HINTING1 SCHEME1 SET1 SHOPPING CART PRICE RULE1 SINGLETON1 SOAP1 SPL2 SQLITE1 SSH1 STACK TRACE1 STDERR1 STDIN1 STDOUT1 SUN1 SYMFONY2 TASMOTA1 TEST TO SPEECH1 TITANIUM2 TRAITS1 TTS1 UBUNTU1 UNICODE2 UTF-82 VECTOR1 WEBKIT1 WINBINDER1 WINDOWS2 WORDPRESS1 WSL21 YAHOO3 YAHOO MAPS1 YAHOO OPEN HACK1 YSLOW1 YUI1 ZCE6 ZCE5.31 ZEND3 ZEND FRAMEWORK3
[A~Z][0~9]

Copyright © 2008 - 2024 CLAUDIU PERȘOIU'S BLOG. All Rights Reserved