Posts

Showing posts from August, 2012

How to setup Eclipse and Android on Windows 7 - A Step-by-Step guide

Image
One of the most detailed step-by-step guide ever to setup Android with Eclipse Juno on Windows 7 and run your first Android Hello World Application Who is this guide for? This guide is for anyone (especially Non-JAVA people from MS world like me), looking for help to setup Android Development Environment on a Windows 7 box. This tutorial (pretty detailed) will help you installing all required software and run a simple Android Hello World project on Android 2.3.3 emulator. When I thought to learn Android (few weeks ago), being accustomed to .msi file double clicks for installation, found Android setup a little less easy. But if you go through this document carefully, setting up android development environment on Windows 7 will be a breeze. Requirements Windows 7 (32-bit or 64-bit) Internet What all this guide covers How to install JDK 7(JAVA Development Kit) How to install Eclipse Juno (Free IDE for JAVA like paid Visual Studio is there for .NET) How to install ADT Plugin (Android de...

Step by step PHP video tutorials from start to finish: part-1

PHP free video tutorials: Hello everyone, this is right place to learn PHP from video tutorials. We consolidate all tutorials from thenewboston and we arrange all PHP video tutorials with step by step manner. Though we have lot of written tutorials on PHP but we think that video tutorials are more effective than written tutorials. That's why we introduce PHP video tutorials only for you. So complete our all PHP video tutorials with step by step procedure. I think you will learn many thinks from our tutorials. To download or watch tutorials just click on skip add button. In this part we give some tutorials for beginners. So start your PHP learning with video tutorials from now. PHP Video Tutorials: Introduction to PHP   PHP Video Tutorials: Installing XAMPP Part 1   PHP Video Tutorials: Installing XAMPP Part 2   PHP Video Tutorials: Creating Your First PHP File   PHP Video Tutorials: Writing Your First PHP File   PHP Video Tutorials: The phpinfo Function Vide...

Step by step blog creation tutorials using PHP & MySQL: Part-2

Image
Today I will discuss Entity or Database analysis of a personal blog. I hope you will enjoy my tutoring. Before starting our tutorial at first read out our first PHP blog creation tutorial.  Step by step blog creation tutorials using PHP & MySQL: Part-1 In this day our discussion is about database analysis. So that we need to know what is database. I say that database is nothing but a storage house that store information with secured way. There are various types of database such as MySQL database, Oracle database, Microsoft SQL server etc. In our whole tutorial we user MySQL database. Because it is free and open source. So guys lets start with us We hope you will enjoy every tutorials from us. PHP blog Database Design: Now we try to design our database for personal blog. Actually we represent all functional features in Database. We represent each function in the database as a table.   Note that we think every feature as a database table. So guys think how many tables we wi...

PHP variable

Image
PHP variable is nothing but a container. In that container we store data. So we can say that PHP variable is a container that store information. Take a look at the picture to understand the PHP variable. PHP variable naming convention:  Each variable has a name. To write variable name we need to follow some rules such as PHP variables start with $ sign. A variable can constitute with letter, number, underscore or dash sign. PHP variable is case sensitive. Here I give some PHP variable examples. $var, $Var, $myVariable, $this_variable, $product, $_book, $__book, $this-variable All of the above rule is right but in PHP we cannot write $this-variable, $_book, $__book  type of variable. Now we try to write a variable example with PHP code. <?php $var=10; echo $var; ?> Save this code with any name and run. This will show 10. If you write same variable many times  in PHP code segment, PHP just count the last variable information such as <?php $var=10; $var=50; $var=100...

Step by step blog creation tutorials using PHP & MySQL: Part-1

Image
Primary discuss of a PHP blog Everyone wants to create personal blog using PHP, though you can use WordPress for personal blog. It is not possible to be a PHP professional without completing any PHP projects. To be an advanced web developers you need to complete more projects such as PHP shopping cart, PHP online exam etc. Here I give you step by step tutorials on personal blog.  This tutorial developed only for advanced users. If you think that you are not an advanced PHP developers just skip this tutorial and try to learn our PHP basic tutorials. Before tending to continue our discussion at first we need to analyze the  primary requirement of a blog. Requirement analysis is very important for future decision. I divide the requirement analysis into two parts.  Functional analysis and  Database analysis or Entity analysis Functional Analysis for Personal blog Functional analysis means what function do a blog. Such functions are login, registration, blog post, catego...

Delete all trailing whitespace in VIM

Delete all trailing whitespace (at the end of each line) :%s/\s\+$//

PHP Bangla Online shop video tutorials

Today I want to share with you PHP online shop Bangla video tutorials. This tutorial not mine, I just collect it from Zakaria Sir. From this tutorial you can easily understand how to build a subtle online shop. It is a simple online shop but from this tutorial you can learn many things with professional way. First off all you need to download a codec and then install it of your personal computer. So guys here the link for those tutorials. To download tutorials, click on the link below and then click skip add. I hope you will enjoy all tutorials from Zakaria Sir thanks.   Download The Codec   Introductory Tutorial Basic PHP Creating HTML Form Formatting Website Creating The Database Display Category PHP Registration Login System Displaying Products Some Professional Website Example Readme.txt   After completing your download try to write every line of code and then try your best to understand each code. If you don't understand any line of code then make sure your comments....

PHP File extension - How to get file extension ?

You can get a file extension in PHP using function pathinfo(). Here is sample usage: $extension = pathinfo( $fileName , PATHINFO_EXTENSION );

PHP switch statement

PHP switch statement is a better alternative than a large series of if-else-if statements. It can switch in different part of the code based on condition. Here is the general form of a PHP switch statement.     switch(expression){ case value1 executed statement; break; case value2 executed statement; break; ……………… default: // default statement } In the PHP switch statement duplicate case values are not allowed. The expression value checks every case iteratively if a match is found then the following case statement is executed. If none of the cases does not matches the value of the expression, then the default statement is executed.

PHP Function default parameter value

You can set default parameter value for method or function by giving it's initial value at argument declaration, see example: function myFunc( $number = 8 ) { } If client will pass a number to that function like myFunc( 11 ), then $number value will be 11. But if user will call it without argument or parameter, the $number variable will have value of

How to remove white space on the left of a strin ?

You can use ltrim() function to remove white symbols at begining of a string, as example shows: $leftTrimmed = ltrim( $oldText );

PHP Store variable in a session

As you propably know, HTTP protocol is stateless, that means that each request run php parser and doesn't know about variables from previous page displayed.You can mantain variable values betweend numerous requests of the same user by storing this varaibles in session. To do that, you just have to call session_start() to start a session (a ID of session will be stored in browser cookies) and add a variable to $_SESSION array.See example below: session_start(); $_SESSION['myvalue'] = 5; Now, if you get $_SESSION['myvalue'] on other user request, you will get value of 5.

PHP Print state of a session

If you want to print all current variables stroed in session just use print_r function, as exaple shows: print_r( $_SESSION ); This will print all varaibles previously set in current session. Don't forget to call session_start() earlier to start a browser session

How to incrase a variable by given value ?

You can incrase a varaible value by number by += operator. If you want to incrase string by appending some data at the end, then use .= operator.See examples below: $number += 10; $string .= " and something";

How to access property of an object in PHP ?

You can access property of an object in php by opeartor ->.Just place it after a object variable, but remeber that accessed property must have valid access like private/protected/public.You can't access a private or protected object property from outside of a class or subclass.Item that you are accessing have to be public. You can access protected properties from subclasses and private properties if you are working with class wich have that property.Here is example how to access a public property in a object: class Sample { public $value; } $object = new Sample(); $object->value = 8; Remeber that good practice says to use getter and setter methods. If your project at some point will needa refactor that accessing some variable needs additional action then you can just change get or set method for that varaible.

Adobe Master Suite CS6 Crack 100% Working

PLEASE +1 TO RECOMMEND THIS TO GOOGLE FOR EVERYONE You are the person who wants to wait for some nice guy to crack the world's nicest software, Adobe's Master Suite CS6 ?? You are at the right place then! You Got Three Steps To Do : 1. Click the below link to download the crack for both x86 and x64 Suites Download 2. Some of you get that crack is not working. The crack works all fine. Make sure you do the usual HOST Editing process of Adobe Installations. Adobe Host Edit for CS5 and CS6 3. Donate a $1 the guy who helped you to get the product of price $2699 to nothing. Donate  via PayPal™

Get last element of an array in PHP

To get last element of an array just use end() function. First idea can by get a index at count()-1 but remember that php arrays are associative arrays, so you can grab last element just by number. $lastElement = end($array); As simple as you see. It works even if your indexes are strings like 'name','surname' etc.

How to get size of an array in PHP (count elements) ?

To count elements and grab size of an array in php just use a count function: $elementsNumber = count( $array ); This will return a number of elements that are set in array

Get random element from an array in PHP

This tutorial will show you how to get a random element from an array in PHP. We will use mt_rand function and count to determine minimal and maximal index of a array. Remeber that arrays are indexed from 0, so if you have a ten elements array, the elements have indexes from 0 to 9. So, we need a random number that will by at least 0 but smaller than 10. Wi will user mt_rand function te generate that number. Se example how to use count and mt_rand to get random element from an array: $array = array( 1,2,3,4,5 ); echo $array[mt_rand(0,count($array)-1)]; As you can see we have to substract 1 from the size of an array. Also we use faster and better function mt_rand, because rand is slower and less randomness.

PHP Print array - how to show contents of an array

You can simple show entire contents of an array by callind print_r function: print_r($theArray); $arrayContents = print_r($theArray,true); Second example show how you can grab output to a variable to parse it or store somewhere (lika a file)

PHP Array add element - how to append element to an array

If you have a PHP array and wants to add element to it, you can do it just in this way: $myArray[] = 'new element'; This will add element to php array at its end

PHP Integer - how to determine if a value is a number in PHP ?

You can check type of a varaible in php calling gettype: $type = gettype( $variable ); var_dump( $variable ); Second line shows another easy way to show variable type, but it works by outputing result and you cannot grab it to variable. But second way can traverse arrays recursive and show all of its contents. Also it will show you all informations about any object.

Comparison of free private source code repositories

If you are a freelancer or have an idea that you wish to develop with a friend (or maybe yourself), it is likely that you are looking for a SVN repository. At the same time you may wish not to opt for public repository which makes your code public to all. If you do not want to invest in a server or expensive online repository accounts, following table may help you. It represents a list and comparison of good source code repository options which provide some level of free usage. Price Size Users Private User Groups Projects Supports FREE Options Spring Loops Free 100 MB 2 Yes No 1 Git, Subversion BitBucket Free Unlimited 5 Yes Yes Unlimited Git, Mercurial Assembla Free 1GB Unlimited Yes No Unlimited Subversion, Git BeanStalk Free 100 MB 1 Yes No 1 Subversion, Git, Mercurial ProjectLocker Free 200MB 2 Yes No 1 Subversion, Git Unfuddle Free 512MB 2 Yes No 1 Subversion, Git GitHub Free Unlimited Unlimited No No Unlimited Git CHEAPEST options xp-Dev $5/mo 2GB Unlimited Yes Yes Unlimited S...

Maximum execution time of 30 seconds exceeded in...

If you encounter this error that means, that work to do by apache web server to handle your taks was long-time nad it was stopped by time limit provided by ini configuration in php. Such task as image resizing or huge files operations can ast long. You can change setting of time limit in PHP by function set time limit, where you give max execution time in seconds as parameter: set_time_limit( 300 ); But be aware. You can hung your server if your job is endless (like never ending loop), so don't set this value too high.

How to measure length of a string ?

If you want to check a length of the string in php, just user strlen() function. It will return the given string length. See example: if ( strlen( $unknownString ) > 10 ) { echo "String has more than 10 characters"; }

How to remove white space in PHP (remove spaces at begining and end of string)?

You can remove trailing and leading white characters in PHP. What is white character ? it's just a character wich we don't see like tab, space, or new line character. To remove white space characters in PHP just use trim() function. It will do the work, here comes two sample codes: $trimmed = trim( $somestring ); echo "[".trim(" hello ")."]"; As you can see you can use this function inline to for example filter output.

How to implement a real life benchmark with PHP

To determine the maximum capacity of a web page, Apache ab is often used in the first step. Fetching one URL very often is optimal for caching and gives a best case . To get the worst case for caching, it is necessary to fetch different URLs in a random order. Here is a PHP script to walk randomly on a web page: To get the average case concerning caching and response times, we need to choose the most relevant links. For example, we skip links from headers and footers. This can be done by using a different xpath expression in the code: // fetch all links under <div id="content">...</div> $xpath = '//div[@id="content"]//a'; // fetch all links under <div id="content"> and <div id="menu"> $xpath = '//div[@id="content" or @id="menu"]//a'; To make the benchmark more realistic, you can define a waiting period between two requests: Uncomment "// sleep(1)" at the end of the scrip...

Why not to use rand() in PHP

The rand() function in PHP is much more older, and doesn't generate such a good results as mt_rand(). What means good ? Just random. Computers cannot create real random numbers, so rand() and mt_rand() are just using some mathematic calculations to create pseudo random numbers, and mt_rand() has better and faster algorithm. Code sample: $i = rand(1,5); // don't use ! $i = mt_rand(1,5); // better If you want to check this, just generate a image with black and white pixels, selecting it by rand and mt_rand 0 and 1 values. You can see some patter-like areas in image created by rand()

mysql_fetch_array and mysql_fetch_assoc difference

Many beginners in php user mysql_fetch_array after using mysql_query. This taking a row from mysql result set and put it's resulting data to an array format. By first look, this work same as mysql_fetch_assoc but the difference is in way that data is put. Assoc is creating less indexes, because it uses only those indexes thar are column names. Mysql_fetch_array will also create values in numered indexes starting from 0, representing next columns. $q = mysql_query("SELECT id,val FROM table"); // This create indexes 0,1,id,val: print_r( mysql_fetch_array( $q ) ); // This create indexes id,val: print_r( mysql_fetch_assoc( $q ) ); So if you are not using indexes like 0, 1 when getting data from your query, but using only associative array keys - don't use mysql_fetch_array to gain performance.

How to randomize array in PHP ?

If you want to random order of elements in your php array, use shuffle function: $somethings = array(); $somethings[0] = "element1"; $somethings[1] = "element2"; $somethings[2] = "element3"; shuffle( $somethins ); Notice that this will modify that array wich you put as a argument (pass by reference)

How to add element to an array ?

If you want how to add or append element to a PHP array, see this code snippet: $somethings = array(); $somethings[] = "element"; // append as last element $somethings[4] = "other element"; $somethings['thekey'] = "some other element";

How to check that one string contains another in PHP

If you want to check if one string contains desired string, you can use strpos function. But be aware - the problem rises when a needle is on position 0 of checked string. In that situation php strpos() returns 0, and it will return false if string is not found. So, to compare if a string is containing user string, use !== operator if ( strpos( $string , 'somestring' ) !== false ) { } Also use === false if you want to check that string doesn't not contains data

jQuery action called twice or more times

If you are begginer in jQuery you can do a common mistake, espacially when dealing with dynamic content, ajax, and dynamic interactive elements. This problem can be non-working action that you have bind to some element (but really did not) or action is evaluated multiple times. To deal with that problem, you must understand how jQuery works. When you add action like .click(function(){....}); you are binding this action only in time when this element exists, so if you provide new element in for exaple AJAX request, it will not react to click. You must bind this event after adding element to DOM structure by calling .click with its selector. Another common problem is that function can be called multiple times. This works this way, because you are binding function to element multiple times. Each time witch executing .click(function(){});. You can clear previously assigned action to that element and call click() to assign fresh, single event listener, like that: $("#mybutton")....

How to call parent constructor ?

If you write your own constructor, you propably will want to call a parent construtor first to set up a class. You can do it in that way: parent::__construct(); This can be used also to call parent methods.

Multiple checkboxes send to array as php

If you have bad experience with making inputs named like cat1,cat2,cat3, there is a way to post to php custom amount of elements within the same field name. If you add [] to your field name, this value will be posted to PHP script as array of values, and you can traverse array easily: Category 1 Category 1 Category 1 // in php: foreach( $_POST['selectedcategories'] as $cat ) { echo "User selected $cat ! "; } Of course, you can generate inputs by php from some source selecion model

Deal with path errors when using mod rewrite and directory-like url

If you are using directory-like url's like this: mysite.com/one/two/three any css or javascript file accesed by "script.js" will be searched in /one/two/three/scrit.js when 404 error will occur. Add a slash symbol at begining of path to access that file from global context like "/script.js". This is also useful for broken mod-rewrite links, like 404 error on /one/two/index.php. Your href attribute should be set to "/index.php" not "index.php" or whole address: "http://mysite.com/index.php". You can write your own href-generating function/class that will append your current domain to every link.

How to pass value to included smarty template

You can pass a variable value to a smarty template while including it. Just type name of a variable as parameter and value in quotas: {include file="fielderror.tpl" fieldname="albums"} Now in fielderror.tpl you can access this variable just by {$albums}

print_r in smarty - How to print your array contents in smarty template.

You can print a array contents like in php print_r() function in smarty tempalte. The common mistake is to forget about second print_r parametr for returning it's output. This parameter have to be set to true. If you forget to set it to true, your array contents propably will be somewhere at begining of a content. This is the solution: {$myArray|@print_r:true} Notice the @ symbol that provides parsing argument as array, not as string.

Filter smarty variable in .TPL file for new lines to br tag

You can filter any smarty variable by using allowed php function as a modifier. For example to put BR tags instead new lines you can do this in smarty template: {$content|nl2br} Good way to output filter or (if you provide own modifier) you can format dates etc.