How to check string in string variable using php

PHP tutorial, we will show you how to check string in php variable using php language. This easy very easy using php language. we given code snippet.

Use can use the strpos function for string to search in

<?php
$mystring = 'abc xyz';
$findme&nbsp;&nbsp; = 'abc';
$check_string = strpos($mystring, $findme);


// because the position of 'a' was the 0th (first) character.
if ($check_string === false) {
 echo "The string '$findme' was not found in the string '$mystring'";
} else {
 echo "The string '$findme' was found in the string '$mystring'";
 echo " and exists at position $pos";
}
?>

create sticky footer using css or javascript

You can create sticky footer using css perfectly. Use following css code for creating the sticky footer. Many people gave example of google sticky footer.

create sticky footer using css or javascript

create sticky footer using css or javascript
create sticky footer using css or javascript

Use bellow CSS code.


html{

height:100%

}

body{

height:100%

}

#footer{

position: relative;

bottom: 0px;

height: 100px;  //You must need to know your footer height

margin-bottom:-100px; //here I am thinking footer will be 100 px

}

You can change the footer height as per your need or footer height.

Sticky footer you will also achieve using javscript code.

<script>// <![CDATA[

// ]]></script>
document.body.onload = function () {
 var myWidth = 0, myHeight = 0;
 if( typeof( window.innerWidth ) == 'number' ) {
 //Non-IE
 myWidth = window.innerWidth;
 myHeight = window.innerHeight;
 } else if( document.documentElement &&
 ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
 //IE 6+ in 'standards compliant mode'
 myWidth = document.documentElement.clientWidth;
 myHeight = document.documentElement.clientHeight;
 } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
 //IE 4 compatible
 myWidth = document.body.clientWidth;
 myHeight = document.body.clientHeight;
 }
 window.alert( 'Width = ' + myWidth );
 window.alert( 'Height = ' + myHeight );

 middle_container = myWidth - 150; // here I am thinking footer and header hight is 150px
 document.getElelmentByID("main").style.height = middle_container;
}
// ]]>

You just need to minus the header and footer height from middle_container.

change image of on MouseOver Event using JavaScript

Using only javascript and CSS you can easily achieve mouseover effect. In article we given sample code for change image of on MouseOver Event in your site.

change image of on MouseOver Event using JavaScript or CSS

change image of on MouseOver Event using JavaScript or CSS
change image of on MouseOver Event using JavaScript or CSS

If you want to change the image on rollover or mouseover event. This is very old technique. You can achieve this using CSS or javascript. I given the simple and powerful code javascript mouse event. I tested this code. It works on all the browsers.

With CSS you can use the following code:


.yourimage { background-image: url('firstImage.jpeg'); }
.yourimage:hover { background-image: url('secondImage.jpeg'); }

<div class=”yourimage” style=”height:100px;width:100px;min-height:100px;min-width:100px;”></div>

I am using the yourimage class for div element.

With javascript you can use following code

<div>
<img src="firstimage.jpeg" onmouseover="this.src='secondimage.jpeg'" onmouseout="this.src='firstimage.jpeg'"/>

If you are using the Jquery then use following code:

<style>
.imagediv{background-image:firstimage.jpg}
<div class="imagediv"/>

 $(document).ready(function () {
            $('div.imagediv').mouseover(function () {
                $(this).css(background-image", "url('secondimage.jpg')");
            });
        });

how to change date format in php

We will show, how to change date format in php code. If you want to change the date format and save into mysql database. You can use our php code or script. You can use following php functions.

how to change date format in php

Let say you are getting date in yyyy-mm-dd format and you want to convert that into dd-mm-yyyy format and save into database. so you can use following function.

$timestamp = strtotime(your date variable);
$new_date = date('d-m-Y', $timestamp);

// or use can following code

$new_date = date('d-m-Y', strtotime(your date variable));

// or use can following code

strftime ($time, '%d %m %Y')
how to change date format in php
how to change date format in php

how to register multiple sidebar in wordpress

Many wordpress developers and PHP developers who are new in to wordpress development. They really searching for how to add a dynamic or multiple side in wordpress theme. many sidebar or widget are very important to add in any wordpress theme for seo purpose also so you can add the widgets using our code sample.

register multiple sidebar in wordpress

Many wordpress developers got requirement to add separate sidebar for each page or any specific page and that sidebar need to be controlled by wordpress admin.

In this tutorial I will show you how to simply add the multiple or dynamic sidebar to wordpress theme. I really think creating the or putting separate css and options in  the sidebar and admin has no control over the sidebar.

Just use my code to create the multiple sidebar in wordpress theme. This following function is provided by wordpress api only. Open your functions.php file from your wordpress theme folder


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
 if(function_exists('register_sidebar'))
 register_sidebar(array(
 'name' => 'Home Page', // The sidebar name you can choose as per your choice to register
 'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
 'after_widget' => 'CLOSE THE DIV',
 'before_title' => '<h2>',
 'after_title' => '</h2>',
 ));
?>

This is sample code for multiple pages your can use following code:


<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
     // Home Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Home Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // Blog Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Blog Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // Contact us Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'Contact Page',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));
     // About us Page sidebar
     if(function_exists('register_sidebar'))
          register_sidebar(array(
          'name' => 'About us',
          'before_widget' => 'PUT YOUR OPENING CSS DIV AND CSS CLASSES AND IDS HERE',
          'after_widget' => 'CLOSE THE DIV',
          'before_title' => '<h3>',
          'after_title' => '</h3>',
     ));

?>

Here is Big question, How can you call the different sidebars and manage it. Go to wordpress admin and you will find and four side bars present in widgets sections as per this code. You can just drag and drop the widgets as your choice.

Open your sidebar.php file put following code in that file.

<?php
is_page('Home Page') {
     if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Home Page')) :
     endif;
}
?>
how to register multiple sidebar in wordpress
how to register multiple sidebar in wordpress

You can use the following type of code in your sidebar.php file as per your condition. If you have any issues get back to me.

How to show recent posts without wordpress plugin

When we are work with wordpress theme. So many times we want to show recent posts without wordpress plugin in wordpress theme.  Many people suggest to use wordpress plugin for showing the recent post.

How to show recent posts without wordpress plugin

But I suggest not to use any wordpress plugin for showing the recent posts in wordpress theme.

In this tutorial I will tell very simple technique to show recent posts. Following code you can use in your sidebar.php or in footer.php or anywhere as per your theme requirement.

Just put following code in your theme file. You just need to change the showposts count as per choice.


<?php
 $recent_posts = new WP_Query('showposts=15');
 while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
?>

Your recent post will look this. You just need to customize css as per your wordpress theme.

show recent posts without wordpress plugin
show recent posts without wordpress plugin

create 404 page in wordpress theme with classic design

Many wordpress theme developer when create new wordpress theme, they need to think about 404 page must. In this article I going to give you information about how to create 404 page in wordpress theme with classic design.

create 404 page in wordpress theme

What is 404 page?

The 404 or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but the server could not find what was requested. 404 errors should not be confused with “server not found” or similar errors, in which a connection to the destination server could not be made at all. Another similar error is “410: Gone”, which indicates that the requested resource has been intentionally removed and will not be available again. A 404 error indicates that the requested resource may be available in the future.

I recommend to wordpress theme developer create customize 404 page in wordpress theme. Go to google custom search engine page and get google search engine code for your website from following URL:

http://www.google.com/cse/

Use following code creating the 404 page in wordpress theme.


<?php get_header(); ?>

<?php get_sidebar(); ?>

<div class="text" style="padding:50px 0 0 150px; ">

<img src="<?php bloginfo('template_url'); ?>/images/octocat_happy.gif">
<h1 class="title">Page Not Found</h1>
<p>We are sorry about!</p>
<p>Please try search again from here:</p><br>

<form action="http://images.purabtech.in/search-result/" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="partner-pub-4949877136251097:p4u7h8-3y7v" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="ISO-8859-1" />
<input type="text" name="q" size="25" />
<input type="submit" name="sa" value="Search" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script>

</div>

<?php get_footer(); ?>

I used here my websites search engine code. Dont forget to change the google search engine code as your web site.

404-error-pages-for-your-website-7 create 404 page in wordpress theme
create 404 page in wordpress theme
The 404 or Not Found error message is an HTTP standard response code indicating that the client was able to communicate with the server but the server could not find what was requested. 404 errors should not be confused with “server not found” or similar errors, in which a connection to the destination server could not be made at all. Another similar error is “410: Gone”, which indicates that the requested resource has been intentionally removed and will not be available again. A 404 error indicates that the requested resource may be available in the future.

Create new sunset effect using PhotoShop

In this article, We given full steps with screen-shot. Using this article you can Create new sunset effect using PhotoShop. We given tips for using photoshop.

Create new sunset effect using PhotoShop

Select a photo, which is having sky  background search in goggle

Now create duplicate of photo

Select brush tool with 20 opacity select black color & fill on ground side to top side on image

Now select new blank layer

Your layer palate & photo has to look like below

Now blank layer fil with black color

In lens flare have 80 percent of brightness

Now select blend option select linear dodge

Your senset is ready now

Create smooth wind effect in PhotoShop

In this tutorial we are going to be show you how to Create smooth wind effect in PhotoShop. we given full steps and snap shots the full description.

Create smooth wind effect in PhotoShop

First select a text here I selected wind

Now select layer >> rasterize >> type
That we can modify our text

Select filter >> stylize >> wind

t is a best tool in PhotoShop that you can use on text
In wind effect have methods wind, blast, and stagger you can also make direction
Front to right or front to left whichever is best for our text we can select
Here is select wind with the direction of front to right

Create smooth wind effect in PhotoShop
Create smooth wind effect in PhotoShop

Now go to filter select liquefy effect
Select fast wrap tools & on the text drag left to right direction
So you wind text effect is ready now

Create red vintage photoshop effect with photoshop

Photoshop tutorial for creating red vintage photo using photoshop. In this tutorial we are going to be showing you how to create a photo effect.

Create red vintage photoshop effect with photoshop

First select one your favorite photo

Here is select this

Now make it duplicate layer & select blend mode darken

Create another blank layer select gradient tool draw a red color effect

One side has to dark red & second side lighted red

Layer palette & photo have to look like given below

Now put anther gradient shade on this layer with yellow & red mix

& Opacity has to 30 percent

Your photo effect is almost done now

Now go to filter >> render >> lightning effects

Now add

Go to image >> adjustment >> brightness/contrast

Your hot photo is ready now

Create red vintage photoshop effect with photoshop
Create red vintage photoshop effect with photoshop