

I began to use Zend Framework
Author: DeVoid
At work develop a project with the use of Zend Framework. To it with wramework’s i did not work, but enough quickly studied basis and beginnings actively to use him. Today I want talk about feelings and considering which arose up in latter days.
First that it should be noted - Zend Framework lays on serious rules on the structure of catalogues. It is good, as a clear structure of project gives to understand at once, where for you Comptrollers, Models and files of templates which are responsible for a kind.
read comments (0)PHP - array_map and callback functions
Author: DeVoid
callback functions of arrays are a very powerful instrument, using which, a programmer can obtain flexibility and simplicity of work with arrays. The callback functions of arrays are created for modification of content of arrays a method “value after a value”.
We will consider the function of array_map(), which in a general view looks so:
array array_map ( mixed $callback , array $array1 [, array $array2... ] )
the first parameter is a function of treatment of array, must work exactly with the that amount of parameters, which you will pass to it. For an example it is possible to consider simple example which will simply illustrate work of this function:
<?php
function format_values($value)
{
return '<b>'.$value.'</b>+';
}
$myarray = array('first', 'second', 'third');
$formatted_array = array_map("format_values", $myarray);
echo('<pre>');
print_r($formatted_array);
echo('</pre>');
?>
As a result of implementation of this code, we will get the values of our array in a bold style. As the first parameter of function of array_map we passed the name of function which will process every value of array $myarray. It should be noted that function of array_map return an array $formatted_array, every value of which is treated the function of format_values.
Resize Jpeg image using PHP
Author: DeVoid
If you created galleries once - you know how important create the small preview images. In PHP we easy can do it. Now we write small function which will change the size of image. If you need show the image preview do it:
<img ALT="preview" SRC="resize.php?url=image.jpg" />
Here file resize.php:
<?
function resize($img_src)
{
header('Content-type: image/jpeg'); list($width, $height) = getimagesize($img_src);
$source_img = imagecreatefromjpeg($img_src);
$dest_img = imagecreatetruecolor(64, 64);
imagecopyresampled($dest_img, $source_img, 0, 0, 0, 0, 64, 64, $width, $height);
imagejpeg($dest_img);
}
if(isset($_GET["url"]))
{
resize($_GET["url"]);
}
?>
Function simple and to explain as it works it is not needed. But if you need change size of many images
- it is needed to understand that this function will strongly slow work of site.
phpDoc in Eclipse - when the comments become more clear
Author: DeVoid
About importance of commenting of a code was spoken already many times. About importance of commenting of a code was spoken already many times.
If you would want that each class written by you was clear to you and your colleagues - can use the simple standard of record of the comments:
/ **
* Short description - used in indexlists
*
* Multiple line detailed description.
* The handling of line breaks and HTML is up to the renderer.
* Order: short description - detailed description - doc tags.
*
* @param string Target directory for the generated HTML Files
*/
If before the announcement of a class or method to write such comment - IDE will process it and will deduce to you the help at their further use. It is very convenient by collective development and large volumes of a code.
The purpose of methods becomes more clear, the transmitted parameters are deduced, the returned meanings are specified.
It is necessary to note that Eclipse automatically generates preparation under such style of the comment after introduction / ** and pressing Enter before the announcement of a method / class. And to receive the help it is possible on pressing Ctrl+Space after input $myClassName- >.
Welcome to Community!
Author: admin
I created this site for programmers, my colleagues, could publish here the ideas, divided experience, to communicate between itself, help novices. Every visitor which will be registered - can write in blog, leave a comment, see the users profiles. I hope you will find here much interesting.

