Best Example PHP Code for Beginners

example php code for beginnersI was remember when learning PHP in first time. Everything is full of mystery and arouse curiosity. A beginner when studying web programming, whether it’s PHP or ASP will be very motivated to make something different. For me, learning takes a example. I could not understand a programming language only with theory, there should be practice. And I need a example source code, so I understand the programming language. Are you also include people like that? if yes, then this post will give some simple examples of PHP code for various purposes.

The script below we take from several sources valid. You can see how the PHP code written by programmers around the world. Read more

2014 Usefull Code Snippet for WordPress 3.8.2

WordPress is a very powerful CMS, used by personal, professional bloggers and large-scale international media. This proves that wordpress is a big part of the internet. WordPress is written in PHP and MySQL database and released as open source. Therefore, the development of wordpress is very fast.

Up to date, wordpress has been used by approximately 77 million domains worldwide, and continues to grow. And has reached version 3.8.2. My first time using wordpress version 2.0 and was very impressed with its features. Moreover, there is support for plugins, so we can add features as needed.

WordPress is very flexible to be developed, because the wordpress source code can be accessed by anyone, there is no section in the codes are encryption. You can add a line of code or 100 lines of code in the wordpress core. But, remember you have to know 100 % what kind of wordpress.

Here are some code snippets that you can add on wordpress. The goal for wordpress works according to what you want. Well, everyone is different purpose, right? Read more

Plyr : Simple HTML5 Javascript Library to Play Multimedia File, Including Youtube and Video Embed

Is a javascript library that allows you to work with a variety of videos, including videos from YouTube and Vimeo. You can configure Libra today to work in accordance with your wishes. Excess plyr is when you embed the video on YouTube, much simpler interface that does not impress the video came from YouTube. To Websites which have a lot of video content I believe plyr is a library that is suitable to handle video content

Other plyr excess is a measure of this library is very small only 10 kilobytes and supports a wide range of features such as

  1. Full screen support
  2. bootstrap support
  3. responsive
  4. keyboard shortcuts

Just download and view plyr demo

How to install Plry

<script src=“path/to/plyr.js”></script>

<script>plyr.setup();</script>

Include the CSS

<link rel=“stylesheet” href=“path/to/plyr.css”>

Download Plyr here

Code Snippet : Pagination Code with CakePHP and Bootstrap

Bootstrap CSS framework is the most widely used by the front end developer, the reason is simple: because the bootstrap supply various kinds of elements that you can use directly. The process of making a website more quickly.

Including pagination element. I as a user cakephp encountered many problems when combining the output pagination of cakephp with bootstrap. To that end, when I found the solution, I post the code here, so easy to remember for myself or others.

<ul class="pagination pagination-large pull-right">
                        <?php
                            echo $this->Paginator->prev(__('prev'), array('tag' => 'li'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));
                            echo $this->Paginator->numbers(array('separator' => '','currentTag' => 'a', 'currentClass' => 'active','tag' => 'li','first' => 1));
                            echo $this->Paginator->next(__('next'), array('tag' => 'li','currentClass' => 'disabled'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));
                        ?>
                    </ul>

I am use :

CakePHP 2.5 and Bootstrap 3.0.3

Resources to Building Pinterest Layout with Bootstrap

bootstrap-layout-pinterest

Pinterest brings a fresh new layout. The developers want to imitate it in various ways, such as by using the bootstrap and javascript. Thus, many released wordpress themes or themes with a layout similar to HTML pinterest. Actually, this layout suitable for a website with lots of pictures, displays a random image with different sizes and trimmed with javascript.
The most popular Javascript is masonry, unfortunately there is no developer who is able to combine perfectly masonry and bootstrapping. Because, I am also looking for him.

Well, although it can not be incorporated perfectly, at least we can still use the bootstrap with javascript (jquery plugin) to create layouts pinterest. Below I detail how to make pinterest style layout with additional bootstrap and javascript.

1. Mansory CSS with Bootstrap

*, *:before, *:after {box-sizing:  border-box !important;}


.row {
 -moz-column-width: 18em;
 -webkit-column-width: 18em;
 -moz-column-gap: 1em;
 -webkit-column-gap:1em; 
  
}

.item {
 display: inline-block;
 padding:  .25rem;
 width:  100%; 
}

.well {
 position:relative;
 display: block;
}

 

<div class="container">
  <h1>Masonry CSS with Bootstrap</h1>
<div class="row">
    <div class="item">
      <div class="well"> 
        1 blah blah blah
      </div>
    </div>
 	<div class="item">
        <div class="well"> 
        2 blah blah blah blah blah blah blah blah blah blah blah blahblah blah blah blah blah blah
        </div>
    </div>
    <div class="item">
        <div class="well"> 
        3 blah blah blah blah blah blah blah blah h
        </div>
    </div>
    <div class="item">
        <div class="well">
        blah blah blah blah 
        </div>
    </div>
    <div class="item">
        <div class="well"> 
          blah blah blah. The container inside the item must be position:relative
        </div>
    </div>
 	<div class="item">
        <div class="well"> 
        blah blah blah blah blah blah blah blah blah blah blah blahblah blah blah blah blah blah
        </div>
    </div>
    <div class="item">
        <div class="well">
        blah blah blah blah blah blah blah blah h
        </div>
    </div>
    <div class="item">
        <div class="well"> 
        blah blah blah blah
        </div>
    </div>
    <div class="item">
        <div class="well"> 
        blah blah blah blah blah blah blah blah blah blah blah blah
        </div>
    </div>
    <div class="item">
        <div class="well"> 
          blah blah blah. The container inside the item must be position:relative
        </div>
    </div>
</div>
</div>

Source

2. Pinstrap – a HTML Template

3. Bootstrap Mansory Template

bootstrap mansory template

Download

4. Simple jQuery Plugin to Create Pinterest Layout

I am use this jquery plugin to build jabirah, its easy to use, fast and client side calculation

pinterest layout

Download

5. Waterfall.js

Its best pinterest layout with javascript, because is combine with infinite scroll. I am prefer to use it, but when deal with infinite scroll, it very hard to implement with my cakePHP.

pinterest layout

Download

Recomended this one.

Gridsby is premium bootstrap theme with pinterest style. If you dont have time to design, you can use it. I am very recomended this stuff.

gridsby

Fully Responsive

Built with a 100% fluid grid system, Fit Coach gives your visitors the ability to browse your site easily on any device. The layout makes booking classes on tablets and mobile devices a breeze.

Download here

 

[Solved] WordPress Shortcode Always Appear on the Top of Content

WordPress shortcode is a feature that makes it easy for developers themes and plugins. With shortcode, we can insert form, element, script, or whatever it is in wordpress editor. It would also allow a user to manage his website.

But there are little problems that have a major impact, namely the content of shortcode always appear at the top of the content. Whereever you put the shortcode, still, the contents of the shortcode will always appear on the top.

<?php
 function my_shortcode(){
 echo 'Hello world';
}

add_shortcode( 'mycode', 'my_shortcode' );
?>

Then, you put the wherever [mycode] in the content,  Hello World will appear in  the top of content. What happened?

Apparently, shortcode should not use echo, because echo prints on the screen.

Shall in your code like this

<?php
 function my_shortcode(){
 return 'Hello world';
}

add_shortcode( 'mycode', 'my_shortcode' );
?>

The above code is the correct code. I use wordpress 4.0 and above and successfully. If not successful, maybe you use wordpress versions differ with you.

I hope this short article will help you. Dont forget to comment below and share this small code to your social network. Thanks you very much