News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Timothy Boronczyk:
Composing Music with PHP
May 29, 2013 @ 10:56:37

Timothy Boronczyk has a recent post to his site with an interesting thing to use PHP for - composing music.

I'm not an expert on probability theory, artificial intelligence and machine learning, and even my Music 201 class from years ago has been long forgotten. But if you'll indulge me for the next 10 minutes, I think you'll find that even just a little knowledge can yield impressive results if creatively woven together into an application. I'd like to share with you how PHP can be taught to compose music.

He shows examples of some basic melodies generated by PHP (not the prettiest) and talks about how he "taught" PHP to get better at it. He transcribed other music into Scientific Pitch Notation and used a Markov process to create a "next note selection" method based on the notes around it. He includes the code for his "robot composer" class with its "train" and "compose" methods and and example of its usage.

0 comments voice your opinion now!
compose music scientific pitch notation markov process train compose

Link: http://zaemis.blogspot.com/2013/05/composing-music-with-php.html

DevShed:
Composing Messages in HTML for MIME Email with PHP
July 30, 2008 @ 14:34:59

DevShed continues its look at sending MIME emails with PHP in the fourth part of the series - a method for sending HTML in the message.

In this article, I'm going to show you how to provide the MIME mailer class with the ability to send email messages in HTML format. This will greatly extend its functionality, so don't miss this tutorial.

They start by reviewing the class they've created so far, including an example of its use. From there they modify it slightly to make it easy to embed the HTML content into the email by adding the addHTML and buildHTMLPart methods.

0 comments voice your opinion now!
compose email tutorial mime html content


Tim Koschuetzki's Blog:
Composing Methods Substitute Algorithmn
August 16, 2007 @ 08:26:00

Tim Koschuetzki has another in his "Composing Methods" series posted today - this one taking a look at something called the "substitute algorithm". It's a method of replacing content in a simpler way than using multiple ifs (as replaced by array functions).

Programming is such a dynamic action that you often find yourself having to replace an algorithmn all together. It will be much easier to do if the current algorithmn is an easy one already. [...] Make sure you decompose your algorithmns as much as you can and use many small methods for it.

His example replaces multiple if statements to search through an array with a simple in_array statement, returning the selected array index from there.

0 comments voice your opinion now!
method compose substitute algorithm replace search method compose substitute algorithm replace search


Tim Koschuetzki's Blog:
Composing Methods Remove Assignments to Parameters
July 06, 2007 @ 10:21:00

In another part of his "Composing Methods" series, Tim Koschuetzki posts about removing assignments to parameters today - working with a temporary variable inside a method rather than the actual passed in value.

When your code assigns to a parameter in a function/method, use a temporary variable instead. [...] It will make your code much more readable and prevents by-reference confusion and therefore big problems in the future.

His example code uses the illustration of calling a price() method in a class to modify the inputVal value based on other inputted information. His suggestion is to not work with the actual inputVal value passed in (so as to avoid issues if it happens to be passed my reference later), but to work with a temporary variable - $result - inside the method.

1 comment voice your opinion now!
method compose remove assignment parameter temporary variable method compose remove assignment parameter temporary variable


PHP-Coding-Practices.com:
Composing Methods Split Temporary Variable
July 04, 2007 @ 11:26:00

On the PHP-Coding-Practices.com blog, there's a tutorial posted from Tim Koschuetzki in his "Composing Methods" series looking at assigning temporary variables.

When you have the same temporary variable assigned to more than once, split it up into two, unless it is a loop variable. [...] Temporary variables have various uses. They can be used as counters in loops, as collecting variables building up a result or as simple containers containing the result of a long-winded expression for easy reference.

He offers suggestions of using temporary variables, including changing references of it after use and making a new temp variable following the second assignment of the first one. Some sample code is included to illustrate the points made.

0 comments voice your opinion now!
temporary variable compose method tutorial temporary variable compose method tutorial


PHP-Coding-Practices.com:
Composing Methods Introduce Explaining Variable
July 02, 2007 @ 07:53:00

From the PHP-Coding_Practices.com site, Tim Koschuetzki has posted an interesting suggestion for developers working with long expressions to make thing simpler - substituting temporary variables for portions of the expression.

Introduce Explaining Variable is particularly useful with long if-statements. You can take each condition, introduce an explaining variable and the conditional logic will read very well. Another occasion is a long algorithm where each step in the calculation can be explained with a well-named temporary variable.

The method is basically the following - declare the temporary variable with part of the expression, replace where needed in the expression, repeat for other parts of the expression. In his example code, he demonstrates its use, pulling out portions of an equation to calculate an item's price to make it much more readable.

0 comments voice your opinion now!
method variable temporary compose substitution method variable temporary compose substitution



Community Events





Don't see your event here?
Let us know!


framework install library community podcast bugfix package release symfony deployment api language voicesoftheelephpant interview series list tips opinion laravel introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework