Logicationz Tech

More Intelligent Solutionz…!

The Ternary Operator – Working same as If-Else

We know, in programming there are three operators named Unary Operator , Binary Operator and Ternary Operator.

Operator’s name itself says that if it is a Unary Operator(e.g. Increment – Decrement operators) than it will take only one operand, If it is Binary operator(e.g. Relational operators) than it will take two operands and if it is Ternary operator than it will take three operands.

As discussed above, Ternary operator takes three operands – a condition, a result for true, and a result for false. It works similar to IF statement. Ternary operator will compact the 4-5 lines of code(IF statement) in to single line. This makes a difference when you will work with big application and writing thousand lines of code.

Look at below links for solutions.

Look at the below example of IF condition code in PHP.

if($a>$b)
{

echo “$a is greater than $b”;
}
else
{
echo “$b is greater than $a”;
}

Now same thing can also be done by Ternary operator.

echo $a>$b ? “$a is greater than $b” : “$b is greater than $a” ;

To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Advertisements

January 3, 2010 Posted by | Helpful Tips and Tricks | , | Leave a comment

Merging Arrays with Reindex and without Reindexing

Hello Friends,

All we know about array_merge(param1,param2) array function in PHP. It may be possible that some begineers didn’t come across this function. For those people, array_merge(param1,param2) will merge two arrays and reindex all elements in array.

<?php

   $merged_array = array_merge($firstarray,$secondarray);

?>

Above code will merge both array ($firstarray and $secondarray) in $merged_array and reindex all element starting from zero index.

But there are some cases in which you need to keep the same indexes(preserve numeric keys) of this arrays in newly created merged array. For this situation you can’t go for array_merge function. You can simply use ‘+’ operator and it will append both arrays without reindexing elements.

<?php

   $merged_array = $firstarray + $secondarray;

?>

This are the two ways in which you can merge two arrays with reindexing and without reindexing.Look at below links for solutions.

To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

January 3, 2010 Posted by | Helpful Tips and Tricks | , | Leave a comment

How to remove index.php from url using .htaccess (mod_rewrite)

For better SEO optimization and make urls more search engine friendly , remove index.php from URL and make it easier to read.

This can be done by writing only two lines in your .htaccess(mod_rewrite in apache) file. Before writing this rule in .htaccess , make sure that your mod_rewrite is enabled(On) in your apache server. Most probably mod_rewrite is enabled in Linux server but for windows server , you need to contact hosting people to make mod_rewrite enabled. You can check this by looking in phpinfo().

Below is the Rules which will remove index.php from URL using .htaccess. Look at below links for .htaccess rules.

 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/

RewriteRule ^index.php$ http://www.%{HTTP_HOST}/ [R=301,NS,L]

Redirect 301 means Moved Permanently so most search engines will remove index.php from URL.

To know more about programming,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

January 3, 2010 Posted by | Helpful Tips and Tricks, htaccess | , , | 1 Comment

For vs Foreach – Difference between For and Foreach

You must familiar with all loops if you are a programmer/developer. There are so many loops available and you can select appropriate one when you develop an application. I found For and Foreach loops almost same. I googled for finding the difference between For and Foreach(For Vs Foreach) but didn’t get any clear idea. Here i am sharing my knowledge about some of difference between For and Foreach loop.

For can be used to run statements for a fixed number of times, foreach can be used to run statements for dynamically generated arrays(may be result of database query).We can also used for loop for dynamically generated array(may be result of database query) but foreach is the ideal way to iterate dynamic array. The reason behind this, we don’t know the index of array as it may be associate result from database query. So if we use foreach than it will iterate the result one by one.

Look at below links for more results.

Foreach will works only and only with arrays.For will works for any logical operation and i will continue until given condition fails.There is not much execution time difference. They works almost same way and same speed as foreach loop will takes time for getting next element while iterating array while for loop will takes time to re-initialize the variable.

In Summary, For loop can be more optimized if we know the count of array and index of array while foreach is better when we have dynamic array without knowing index of array and size of an array.

To know more about programming,JavaScript issues,jQuery,Expression Engine,MYSQL database,php info,php editor,programming php,Open-source,php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

January 3, 2010 Posted by | Helpful Tips and Tricks | | Leave a comment

How to redirect www to non-www and non-www to www URL using .htaccess (mod_rewrite)

Websites can be access with www and without www also. Since Search engines consider http://www.logicationz.com and http://logicationz.com different websites, it might be a case of duplicate content. So you must stick your domain name accessible either with www or without www.

This can be done by writing only two simple lines in your .htaccess file(mod_rewrite in apache). Before writing this rules in .htaccess , make sure that your mod_rewrite is enabled(On). Most probably mod_rewrite is enabled in Linux server but for windows server you need to contact hosting people to make mod_rewrite enabled. You can check this by looking in phpinfo().

Below is the Rules which will redirect all www requests to non-www URL.

RewriteCond %{HTTP_HOST} ^www.logicationz.com$ [NC]
RewriteRule ^(.*)$ http://logicationz.com/$1 [R=301,L]

Redirect 301 means Moved Permanently so most search engines will send visitors directly to the www version of your URL.

Below is the Rules which will redirect all non-www requests to www URL.

RewriteCond %{HTTP_HOST} ^logicationz.com [nc]
RewriteRule (.*) http://www.logicationz.com/$1 [R=301,L]

Redirect 301 means Moved Permanently so most search engines will send visitors directly to the non-www version of your URL.

What you need to do is just replace logicationz with your domain name. Look at below links for more .htaccess rules.

google_protectAndRun(“ads_core.google_render_ad”, google_handleError, google_render_ad);

January 3, 2010 Posted by | htaccess | Leave a comment

Introducing the google chrome OS

It’s been an exciting nine months since we launched the Google Chrome browser. Already, over 30 million people use it regularly. We designed Google Chrome for people who live on the web — searching for information, checking email, catching up on the news, shopping or just staying in touch with friends. However, the operating systems that browsers run on were designed in an era where there was no web. So today, we’re announcing a new project that’s a natural extension of Google Chrome — the Google Chrome Operating System. It’s our attempt to re-think what operating systems should be.

Google Chrome OS is an open source, lightweight operating system that will initially be targeted at netbooks. Later this year we will open-source its code, and netbooks running Google Chrome OS will be available for consumers in the second half of 2010. Because we’re already talking to partners about the project, and we’ll soon be working with the open source community, we wanted to share our vision now so everyone understands what we are trying to achieve.

Speed, simplicity and security are the key aspects of Google Chrome OS. We’re designing the OS to be fast and lightweight, to start up and get you onto the web in a few seconds. The user interface is minimal to stay out of your way, and most of the user experience takes place on the web. And as we did for the Google Chrome browser, we are going back to the basics and completely redesigning the underlying security architecture of the OS so that users don’t have to deal with viruses, malware and security updates. It should just work.

Google Chrome OS will run on both x86 as well as ARM chips and we are working with multiple OEMs to bring a number of netbooks to market next year. The software architecture is simple — Google Chrome running within a new windowing system on top of a Linux kernel. For application developers, the web is the platform. All web-based applications will automatically work and new applications can be written using your favorite web technologies. And of course, these apps will run not only on Google Chrome OS, but on any standards-based browser on Windows, Mac and Linux thereby giving developers the largest user base of any platform.

Google Chrome OS is a new project, separate from Android. Android was designed from the beginning to work across a variety of devices from phones to set-top boxes to netbooks. Google Chrome OS is being created for people who spend most of their time on the web, and is being designed to power computers ranging from small netbooks to full-size desktop systems. While there are areas where Google Chrome OS and Android overlap, we believe choice will drive innovation for the benefit of everyone, including Google.

We hear a lot from our users and their message is clear — computers need to get better. People want to get to their email instantly, without wasting time waiting for their computers to boot and browsers to start up. They want their computers to always run as fast as when they first bought them. They want their data to be accessible to them wherever they are and not have to worry about losing their computer or forgetting to back up files. Even more importantly, they don’t want to spend hours configuring their computers to work with every new piece of hardware, or have to worry about constant software updates. And any time our users have a better computing experience, Google benefits as well by having happier users who are more likely to spend time on the Internet.

We have a lot of work to do, and we’re definitely going to need a lot of help from the open source community to accomplish this vision. We’re excited for what’s to come and we hope you are too. Stay tuned for more updates in the fall and have a great summer.

January 2, 2010 Posted by | Google | , , | Leave a comment

All New Google Wave!

Google Wave is an online tool for real-time communication and collaboration. A wave can be both a conversation

and a document where people can discuss and work together using richly formatted text, photos, videos, maps, and more.

What is a wave?

A wave is equal parts conversation and document. People can communicate and work together with richly formatted text, photos, videos, maps, and more.

A wave is shared. Any participant can reply anywhere in the message, edit the content and add participants at any point in the process. Then playback lets anyone rewind the wave to see who said what and when.

A wave is live. With live transmission as you type, participants on a wave can have faster conversations, see edits and interact with extensions in real-time.

December 29, 2009 Posted by | Google | , | 1 Comment

Gigabyte Announces USB 3.0 Motherboard Microsite

Gigabyte Technology announced the launch of the Gigabyte USB 3.0 microsite to help drive adoption of the new SuperSpeed interface within the PC industry. The new microsite is a source for information about USB 3.0 features, performance, Gigabyte motherboards with USB 3.0 capabilities, compatible 3rd party USB 3.0 devices and also where to buy information.

Gigabyte currently offers 11 USB 3.0 motherboard models that cater to a wide range of high-end and mainstream price points and preferences, and were planning on launching several new entry level models in the near future so that more Gigabyte motherboard users will be able to benefit from SuperSpeed data transfer, said Tim Handley, Deputy Director of Motherboard Marketing at Gigabyte Technology Co. Ltd. We hope to work with every USB 3.0 device vendor to ensure compatibility and the best quality products and experience for our customers.

December 29, 2009 Posted by | Computer | , | Leave a comment

Bulletproof & Flexible Layouts Made Simple

“Yet Another Multicolumn Layout” (YAML) is an (X)HTML/CSS framework for creating modern and flexible floated layouts. The structure is extremely versatile in its programming and absolutely accessible for end users.

  • Based on web standards
  • Designed for accessibility
  • Robust, flexible layout concept
  • Modular construction, user-oriented functionality
  • Complete multilingual documentation

Information

Examples and Documentation

Community

Recently discovered www.Ping.fm and it blew my mind.

We’ve put together a little feature to help your blogs and websites gain some social traction. Not only that, but you can ping the awesome stuff you’ve create or run across right from your browser.

Introducing “Ping this!”

Add Ping this! links to your blog so your readers/users can link your article of interest straight to their favorite social networks right from your website.

Click here to get in on it

December 28, 2009 Posted by | Uncategorized | | Leave a comment