Archive: php

 

Posts Tagged ‘php’


If you are having issues running unit tests that work with sessions and call session_start(), you might see error messages like this: output started at "PHPUnit/Util/Printer.php:173" If you do, the solution is fairly simple. Just add the flag --stderr to PHPUnit eg PLAIN TEXT CODE: phpunit --stderr mytest.php If you are using Netbeans, you simply [...]



 

Encrypting a string in Magneto is really easy and will use the encryption key specified in the local.xml file: PLAIN TEXT PHP: <?php $encryptedData = Mage::helper('core')->encrypt("This will be encrypted"); There is one problem that you may encounter that can be a little bit problematic but there is an easy work around. The encryption process will [...]



 

If you ever need to create a custom field to save data against a customer in Magento you will probably need to create a custom attribute. Creating the attribute is easy, in your modules install script you do: PLAIN TEXT PHP: <?php $installer = $this; $installer->startSetup(); $installer->addAttribute('customer', 'my_custom_attribute', array('type'=>'text')); $installer->endSetup(); Then on the customer object [...]



 

One of the features that makes PHP such a powerful language is it's arrays. They allow for really complex data structures to be stored and worked on really easy. One interesting aspect of them is that they maintain there index if emptied one element at a time. Taken from php.net: http://php.net/manual/en/language.types.array.php PLAIN TEXT PHP: <?php [...]



 

When creating use input forms in Magento it's important to do as much validation on the client side as possible to make the user experience as smooth as possible. When validating that one of a group of radio buttons is selected all you should need to do is add the class "validate-one-required-by-name" to one or [...]



 

What can be true and false at the same time? PLAIN TEXT PHP: $a = "a"; $b = 0;   if($a == true && $b == false && $a == $b) {     echo "Passed"; } This is because PHP tries to convert "a" to a numeric, as there is no numeric value it [...]



 

Reading the generally very clear and concise Yii documentation you can quickly get started with the framework. However one issue that I struggled to be clear on is setting up the database driven authorisation system. I recommend reading this blog post which finally helped me to understand wth I was supposed to do. The official [...]



 

If you want to serve up text files for download (perhaps product feeds etc) then you might like this little snippet. Not only will it force the file to be downloaded but it allows you to specify a custom filename that it should be saved as. PLAIN TEXT PHP: if(isset($_GET['download_file'])){     header("Content-type: application/octet-stream");   [...]



 

The first development release of Magento 2 has a few areas worthy of note for developers of the coming changes to Magento. Magento 2 now requires PHP 5.3 Zend is still version 1.11.1. Magento 2 now implements templates on a per modules basis. So now all the different bits of the theme are separated into [...]



 

Magento version two is coming. For those of us who are eagerly awaiting the next major version of the most popular and powerful open source e-commerce platform, you can now see, track and download the code on GitHub. Not had chance to have an in depth look as yet but we expect great things! https://github.com/magento/magento2 [...]