Thursday, 15 June 2017

The best way to make connection to your database in PHP

At the essential level the MySQL, MySQLI and PDO augmentations answer the question how would I communicate with the database? They all give capacities and usefulness to associate with a database and send and retrieve information from it. You can make use of them all.

MySQL* is a very simple extension that basically allows you to connect to the database, send it SQL queries and not much else.

MySQL enhances this (as the name proposes) by including parameterized questions and a couple of different things in mix.

MYSQL is deplored now utilize MSQLI or PDO (favored). So as to communicate with a database, particularly MySQL database, the main thing we have to do is connecting to the database, there are numerous approaches to do it, so this time, we'll examine how to connect MySQL Database utilizing PHP.

PHP is developing, its capacities are ceaselessly created and kept up. For a few reasons, some of them were removed including functions connecting to MySQL database.
PDO is viewed as the most recent and the best. In the event that you need to utilize MySQLI, go right ahead yet PDO is better.

You can use MYSQLI or PDO. Both are object oriented, but MySQL also offers a procedural option. And both support prepared statements to avoid sql injections. However, I personally prefer MSQLI because it’s syntax is easier! And I’m use to MySQL but PDO is faster and safer but still MYSQLI can also get the work done.

Note: Functions in this instructional exercise likewise works with MariaDB database (The "Sister" of MySQL).

As a rule, when we need to connect with MySQL Database Using PHP, we utilize the accompanying functions:

<?php
mysql_connect()
mysql_select_db()
mysql_close()
?>

Today, the above strategy turns into an old school method. Along these lines, despite everything those functions you ought to stop it at this moment, in light of the fact that, PHP 7 at no time in the future wouldn't accept those functions. That is on the grounds that it is outdated, loaded with terrible practices and does not have some present day highlights. Try not to use it to develop new applications.

Right now, PHP gives two approaches to connect PHP to MySQL server, using MySQLi (MySQL Improvement) and PDO (PHP Data Object).

Connect MySQL Database Using PHP

There are two ways to connect MySQL database using PHP, both by using MySQLi and PDO. As we have discussed both.

Using MySQLi to connect to MySQL Database


For procedural programming, use mysql_query() function with some parameters: mysqli_connect('db host', 'db username', 'db password', 'db name'), for example:


<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'sociallabs');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);

if (!$db) {
    echo "Error: " . mysqli_connect_error();
 exit();
}
echo 'Connected to Database!';
?>

For OOP way, the format is similar, we only need to add a new keyword: new mysqli ('db host', 'db username', 'db password', 'db name'), for example:

<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'sociallabs');
$db = new mysqli(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);

if ($db->connect_error) {
    echo "Error: " . $con->connect_error;
 exit();
}
echo 'Connected to Database!';
?>


Some possible error may happen while running the above code:
  • Error: Access denied for user ‘@’ localhost ‘to database’ sociallabs’ means that MySQLi can’t login into MySQL database using the provided user name and password.
  • Error: Unknown database ‘sociallabs’ means that the login was successful but MySQLi can’t find sociallabs database.

Complete example:


<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'sociallabs');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);

if (!$db) {
    echo "Error: " . mysqli_connect_error();
 exit();
}

//query databse
$querycomment = $db->query("SELECT * FROM comments");
while ($row = mysqli_fetch_array($querycomment))
{
 echo $row['id'];
}
// Close connection
mysqli_close ($db);
?>


Sunday, 21 May 2017

Which Should I Learn First PHP or MYSQL?

Which Should I Learn First PHP or MYSQL? I always think that the programming language should come first. PHP -› MYSQL. On the off chance that it’s about picking one to learn initially, then it ought to be PHP. When you start learning PHP, then as you progress, you will see the need of communicating with database, and all things considered MySQL will fit in exceptionally well and afterward you can learn MySQL as well. Be that as it may, such a circumstance would not be there the other way around. So starting first with PHP would without a doubt turn out to be better.

Simply get fundamental learning and comprehension of PHP. Once you’re sure you can begin compose basic projects or application which does not include database. After that learn Mysql or any database and do some basic login and validation application.

MySQL is a fine tool, however in the event that will learn it I would recommend that you begin with MySQL, however individuals are beginning to feel dubious about MySQL itself, since it's presently in the hands of Oracle.
Learning MySQL or MariaDB is still unquestionably a significant thing to do, and I exceptionally recommend it. Furthermore, what you would realize Postgres and Sqlite3, which are additionally worth learning.
Take a look at http://www.w3schools.com/php/default.asp :). After you will reach some knowledge’s, it will help you to work with database(db).

When you want to go ahead with more mind boggling application then work on center or enormous application ventures or learn both simultaneously.

You might be able to get a short free trial on safaribooksonline.com (O'Reilly's site) and investigate which one most interests to you. Here are several books to take a look at.
  • 1.      Learning PHP, MySQL, and JavaScript By: Robin Nixon Publisher: O'Reilly Media, Inc. Print ISBN-13: 978-0-596-15713-5
  • 2.      Head First PHP & MySQL By: Lynn Beighley; Michael Morrison Publisher: O'Reilly Media, Inc. Print ISBN-13: 978-0-596-00630-3
Some open libraries have these books also.

PHP is immense, and decent to utilize. All hosts support it, and it's been around sufficiently long for a group to work around it. When you get your comprehension of how a PHP communicates with a database, and how connections work in a database you're prepared for developing a great system. Try not to tune in to the PHP haters either, PHP is getting to be noticeably mainstream again yet as new systems that simply expand on the information you've picked up of learning PHP.

I exceedingly recommend PHP, it's what my group and I utilize. web programming is entirely fun. Cooperation is a whole lot more reasonable.
I know that someone can make good PHP code, but it the experience with the vast amount of bad code that sets people's opinions of the language. I have been fortunate enough to go away from the bad code and create new applications with laravel lately, however, it never seems to compare with the beauty of working with rails.I feel that you can do well in any language, you just need to apply proper design principles, know your code smells, and test. I was really happy when I found guard-phpunit2 the other day as it has improved the way I code in PHP a lot. -tmuntan1
You ought to put your time in a language that you want to utilize. PHP may have more assets and more employments accessible, yet in the event that you don't care for the language then don't land a position utilizing it. As for PHP, I would learn but it's common now. Nothing against it.

It's a good idea to learn PHP eventually, since it's so common.




Thursday, 18 May 2017

Facebook Notification Database Structure Approach

I have been investigating how to build a notification system on Thewallclone social network system and somewhere else and got myself attracted to the arrangement that worked.

A notification is about activities (friendship.). Here is a standardized database structure (however I've used                InnoDB).You need to notify certain users about changes. So it's per-user notifications. implying that if there were 10 users included, you create 10 notification.

One the most critical part of social network system is the ablity to notify users of activities, which keep the discussion fascinating. Here will figure out how facebook notification system functions, this is my approch and it worked for me.

Designing a social network system is one of the tough system you would ever work on.

There are few thing to consider

Things to consider are outlined.
  1. Comment
  2. likes
  3. unlike
  4. Follow
  5. Page Likes
  6. Page Post Like and so forth
These are few we will cover on this article, underneath is our database structure that would contain what we have said aboved.

--
-- Database: `sociallabs`
--

-- --------------------------------------------------------

--
-- Table structure for table `notify`
--

CREATE TABLE IF NOT EXISTS `notify` (
  `nid` int(11) NOT NULL AUTO_INCREMENT,
  `user_one` int(11) NOT NULL,
  `user_two` int(11) NOT NULL,
  `type` varchar(50) NOT NULL,
  `post_id_fk` int(11) NOT NULL,
  `page_id_fk` int(11) NOT NULL,
  `dated` varchar(50) NOT NULL,
  PRIMARY KEY (`nid`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=150 ;

In this way, the Nid field will be set to foreign key of our table, with the end goal that it would auto increment record on each new record inserted into our table.

user_one would be the first user, who claim the post or page, while the user_two would be the second user who make the move, for example, like, comments, follow, as take after and so on.

post_id_fk would be the remote key for related with the post while page_like_fk is the foerign key joined to the page id during creation.


Type is the kind of activity that will be such her the comment, like, follow etc

dated is the time at which the move were made.

PHP Comment code


<?php
//inset into nofication table
 $db->query("INSERT INTO notify (user_one, user_two, type, postid_tk, status, dated)
  VALUES( '$userid_fk', '$uid', 'comment', '$postid', '1', '$time')");

?>

PHP Like code

<?php
 //inset into nofication table
 $db->query("INSERT INTO notify (user_one, user_two, type, postid_tk, status, dated)
  VALUES( '$userid_fk', '$uid', 'like', '$likepostid', '1', '$time')");
?>

PHP notification sample code

<?php 
$up=$db->query("SELECT * FROM notify WHERE status='1' AND user_one='$log_id' AND user_two!='$log_id' ORDER BY nid DESC");
               $countNoti=mysqli_num_rows($up);
               if ($countNoti) {
                 # code...
                echo'<span id="HW_badge" class="HW_visible" data-count-unseen="'.$countNoti.'">'.$countNoti.'</span></a>';
             
               }

  if ($countNoti) {
    $navId=0;
  while($data=mysqli_fetch_assoc($up))
  {
    $navId+=1;
    $user_one=$data['user_one'];
    $user_two=$data['user_two'];
    $ctype=$data['type'];
    $postid_tk=$data['postid_tk'];
    $pageid_fk=$data['page_id_fk'];
    $dated=$data['dated'];
    $nid=$data['nid'];

    $cpost=$db->query("SELECT * FROM post WHERE id='{$postid_tk}' ");
    $dat=mysqli_fetch_assoc($cpost);
    $message=$dat['message'];
    //$page_post_id=$data['update_id'];

    $utwo=$db->query("SELECT * FROM users U, user_bio UB WHERE U.uid='{$user_two}' AND UB.uid=U.uid ");
    $twou=mysqli_fetch_assoc($utwo);

    $query = $db->query("SELECT * FROM updates WHERE  update_id='{$postid_tk}' ");
    $row=mysqli_fetch_assoc($query );
    $user_id=$row['user_id_fk'];
    $messages=$row['message'];
    $p_id=$row['update_id'];

    $setid= $db->query("SELECT * FROM groups WHERE group_id='{$pageid_fk}'");
    $countPagePost=mysqli_num_rows($setid);
    $items=mysqli_fetch_array($setid);
    $pageName=$items['group_name'];
        //$pageName=$pdata['group_name'];

switch ($ctype) {
  case 'comment':
    # code...
    $ctype= "Publised a comment on your post - <a href='readtweet?story_id=$postid_tk' style='color:white;' title='Read story'>".convert_clickable_links(substr($message,0,70)).'...</a>';
    break;
  case 'like':
    # code...
    $ctype= "likes your post - <a href='readtweet?story_id=$postid_tk' style='color:white;' title='Read story'>".convert_clickable_links(substr($message,0,70)).'...</a>';
    break;
    case 'dislike':
    # code...
    $ctype= "dislikes your post  <a href='readtweet?story_id=$postid_tk' style='color:white;' title='Read story'>".convert_clickable_links(substr($message,0,70)).'...</a>';
    break;
    case 'followed':
    # code...
    $ctype= "followed you on Wall
To share and get the latest, follow <a href=".$twou['username']." >".$twou['username'].'</a> back';
    break;
    case 'pagecomment':
    # code...
   $ctype='commented your post on <a href=page?name='.$pageName.'>'.$pageName.' page</a> - <a href="pagestory?story_id='.$p_id.'" style="color:white;" title="Read story">'.convert_clickable_links(substr($messages,0,70)).'...</a> ';
    break;
     case 'pagePostLike':
    # code...
    $ctype='liked your post on <a href=page?name='.$pageName.'>'.$pageName.' page</a> - <a href="pagestory?story_id='.$p_id.'" style="color:white;" title="Read story">'.convert_clickable_links(substr($messages,0,70)).'...</a> ';

    break;
    case 'dispagePostLike':
    # code...
     $ctype='Disliked your post on <a href=page?name='.$pageName.'>'.$pageName.' page</a> - <a href="pagestory?story_id='.$p_id.'" style="color:white;" title="Read story">'.convert_clickable_links(substr($messages,0,70)).'...</a> ';

    break;

    case 'pageLike':
    # code...
    $ctype= "is following ".$pageName.' page';
    break;

  
  default:
    # code..                  
  $ctype="more on your";
    break;
}


 $img= '<img src="user_img/'.$twou['username'].'/'.$twou['img'].'" class="img-circle img-nav" alt="user profile image"> ';
               

        echo '<div class="alert messageBox" id="removeNav'.$nid.'">
        <span class="closebtn" id="navAction" name="'.$nid.'" rel="'.$navId.'">&times;</span> 
        
                                  
                                  '.$img.'

                                  <a href="'.$twou['username'].'" title="'.$twou['name'].'" target="_self"><strong>'.$twou['name'].'</strong></a> '.$ctype.'

                                  <p><small>  <i class="fa fa-clock-o"></i> '.time_passed($dated).' </small> </p> 
                                </div>';

       // echo "$twou[username] commented on your post".strlen($dat['message']);
//echo $data['username'];
                                
      } 
    }
    else
    {
      echo '<span class="alert alert-danger">No notifications</span>';
    }
      
      ?>                             

Learn to Code HTML and CSS: Develop and Style Websites

In case you're absolutely new to website design or on the off chance that you require a revive, this is a decent place to begin. In this course will figure out how to compose HTML and CSS which are the fundamental building pieces of any site. Try not to stress on the off chance that you've never composed a solitary line of code some time recently.

In the event that you can, envision a period before the innovation of the Internet. Sites didn't exist, and books, imprinted on paper and firmly bound, were your essential wellspring of data. It required a lot of exertion—and perusing—to find the correct snippet of data you were after.

Today you can open a web program, bounce over to your web crawler of decision, and hunt away. Any piece of believable data rests readily available. What's more, odds are somebody some place has designed a site in light of your correct hunt.

In this blog you will learn the best practices to design your own particular sites utilizing the two most overwhelming innovations—HTML and CSS.

Before we start our excursion to figure out how to design sites with HTML and CSS, it is essential to understand the differences between the two languages, the syntax of each language, and some common terminology.

HTML is the standard markup language for creating Web pages.
  • HTML stands for Hyper Text Markup Language
  • HTML describes the structure of Web pages using markup
  • HTML elements are the building blocks of HTML pages
  • HTML elements are represented by tags
  • HTML tags label pieces of content such as "heading", "paragraph", "table", and so on
  • Browsers do not display the HTML tags, but use them to render the content of the page

Example

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

Example Explained

The <!DOCTYPE html> characterizes this record to be HTML5

The <html> component is the root component of a HTML page

The <head> component contains meta data about the archive

The <title> component indicates a title for the record

The <body> component contains the noticeable page content

The <h1> component characterizes a substantial heading


The <p> component characterizes a passage


In our next article, we figure out how to Design custom site pages with a picture exhibition and contact page. At last, we stroll through how to share a site live on the web.

10 Awesome PHP snippets

10 Awesome PHP snippets

Welcome back, developer's. this article will make a long running on your coding life, underneath are beat 10 valuable pieces i made sense of and most likely thought would be helpful to you. 

These php tips, you may require them on your improvement procedure, and beyond any doubt you require a work round examples. 

These code are helpful and you gone over them more often than not, the easily overlooked detail that matter most, means the most.

1 } How to sanitize user input


You are told the greater part of your coding profession not to trust client's info, it may be spam or infusion, not 100% immaculate, clean and channel clients information is the best alternative, yet that is not 100% secured either but rather felt smidgen safe and secured, beneath is a capacity to clean client's contribution before putting away to your database.

&lt;?php
function cleanInput($text)
{
 //strip tags
 $text = strip_tags($text);
 $text = trim($text);
 return $text;
}
?&gt;

The most effective method to utilize work

&lt;?php
// chow to use function
$name=cleanInput($_POST['name']);
?&gt;

2}  Step by step instructions to approve Email address with PHP

It's essential to approve client email before putting away and planing to utilize them for any reason, i at some point get a kick out of the chance to confirm email deliver just to make certain is not spam and legitimate email. 

With PHP "FILTER_VALIDATE_EMAIL" rest guaranteed a touch of no spam, so you might need to utilize this capacity to legitimate email address is extremely helpful.

&lt;?php
function Is_email($email)
{
 //If the input string is an e-mail, return true
 if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
  return true;
 } else {
  return false;
 }
}
// chow to use function
$email=Is_email($_POST['email']);
?&gt;

3} PHP how old am I? reveal to me my age

This capacity is exceptionally great pleasant, seen on different stage making inquiry identified with this, for the individuals who are taking a shot at online networking stage, this would be extremely useful, telling your client how old they are. 

Note: you can even utilize this capacity to send glad birthday message, at whatever time it coordinates that 'Day and Month' simply let them despite everything you recall that them as your exceptional clients. it proves to be useful too. 

See demo: enter Day, Month And Year to perceive how old are you... 

Note: you might need to change "DateTimeZone" is exceptionally welcome or better still use without timeZone.
Please read more on  Date and Time Related Extensions

&lt;?php
//with timeZone.
function howOldAmI($age)
{
  $tz  = new DateTimeZone('Europe/Brussels');

$age = DateTime::createFromFormat('d/m/Y', $a, $tz)-&gt;diff(new DateTime('now', $tz))-&gt;y;
     return $age;
}
    
     echo howOldAmI('21/04/1993');

    // without timeZone.

function Tellage($b)
{
     $_age = floor((time() - strtotime($b)) / 31556926);
     return $_age;
}
  // echo Tellage('1993/04/21');
?&gt;

4} PHP GET List Of FILES NAMES FROM A Directory

Step by step instructions to Get All Files Names From A Folder. 
This bit beneath will list/demonstrate all your record names in separate of their document augmentations 
In the event that you at any point needed to flaunt your documents name on your envelope, then this script is ideal for you.

&lt;?php
$dir_path = "folder/"; //directory
$options = "";
if(is_dir($dir_path))
{
    $files = opendir($dir_path);
    {
        if($files)
        {
          while(($file_name = readdir($files)) !== FALSE)
          {
              if($file_name != '.' &amp;&amp; $file_name != '..')
              {
               // select option with files names
               $options = $options."&lt;option&gt;$file_name&lt;/option&gt;";   
               
               // display the file names
               echo $file_name."&lt;br&gt;";
              }
          }
        }
}
}

?&gt;


&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        
    &lt;title&gt;PHP GET List Of FILES NAMES FROM A Directory &lt;/title&gt;
    &lt;/head&gt;
    
    &lt;body&gt;
        
        &lt;select&gt;
            &lt;?php echo $options;?&gt;
        &lt;/select&gt;
        
    &lt;/body&gt;
&lt;/html&gt;

5} How to create SEO friendly URL with PHP

Have a perfect cordial url is the request of the day, each body need to keep up SEO standard, if require url like this http://www.codexpresslabs.info/how-to-outline login-page-for-web then you don't need to look any further on this issue, i got you secured. with clean URL work you can have a pleasant looking, amicable and engaging Url for your site or blog.


&lt;?php
function cleanURL($string) {
   $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
   $string = preg_replace('/[^A-Za-z0-9\-]/', '-', $string); // Removes special chars.

   return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
}
//How to use this function
$url=cleanURL($url);
?&gt;

6} Function to converting time to ago format

This is aPHP work with class HowLong, having somethis like this 3 weeks ago, 1 min ago or an hour ago, this capacity would be awesome for web informal community application, of discussion base framework, demonstrating clients to what extent they have been on the web and when last they login and so forth utilizing PHP timestamp.

&lt;?php
function HowLong($timestamp){
 
     $difference = time() - $timestamp;
     $periods = array("sec", "min", "hr", "day", "week", "month", "year", "decade");
     $lengths = array("60","60","24","7","4.35","12","10");
     for($j = 0; $difference &gt;= $lengths[$j]; $j++)
      $difference /= $lengths[$j];
      $difference = round($difference);
     if($difference != 1) $periods[$j].= "s";
      $text = "$difference $periods[$j] ago";
      return $text;
    }
 
// How to use this function
$time=(1482698697); //$timestamp time()

echo HowLong($time);
?&gt;


Note: this can display a long time ago, even decades.

7} How to create secured PHP login function


Approving clients qualifications is a decent method for limiting approve access to some discharge some portion of your site, potentially which is mean for enlisted clients. this capacity will approve, purify each client email and secret key before conceding access to clients, you might need to attempt this on your next venture.

&lt;?php
//database configuration
session_start();
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'sociallabs');
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);

//loginfunction start
function loginVal($db, $email, $password)
{
$error="";
if (isset($_POST['email']) &amp;&amp; ($_POST['password'])) {

$email = trim($_POST['email']); //Storing email in $email variable.
$password = ($_POST['password']); //Storing password in $password variable.


  if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) {

   
$match = $db-&gt;query("SELECT * FROM users WHERE email='{$email}' AND password='{$password}' "); 
$data = mysqli_fetch_array($match); 
$user_id= $data['uid'];
$fname = $data['fname'];
$lname = $data['lname'];
$email = $data['email'];

if(mysqli_num_rows($match)==1){ //if there is such email and password.
$_SESSION['uid']=$user_id; //Storing user ID in SESSION variable.
$_SESSION['fname']=$fname; //Storing First name in SESSION variable.
$_SESSION['lname']=$lname; //Storing Last name in SESSION variable.
$_SESSION['email']=$email; //Storing EMAIL in SESSION variable.


$_SESSION['AutenUsera']=0; //SET TO FALSE.
if(($_SESSION['email']=$email) and ($_SESSION['password']=$password)){
$_SESSION['AutenUsera']=1; //SET TO TRUE.
echo "&lt;meta http-equiv='refresh' content='0; index.php'&gt;"; //if successful redirect to secured page
}

}
else
{
  $error='&lt;div id="top-blurb-error"&gt;
            &lt;span id="error-signing-in" &gt;Oops!, Invalid email or password!&lt;/span&gt;
          &lt;/div&gt;';
// error message to display
}

  } else {
   $error=('&lt;div id="top-blurb-error"&gt;
            &lt;span id="error-signing-in" &gt;Oops!, '.$email.' is not a valid email address !&lt;/span&gt;
          &lt;/div&gt;');
  }
 }
 
 $db-&gt;close();
}
// How to use this class
echo loginVal($db, $email, $password);
?&gt;

8} How to extract Youtube url from post

On account of PHP group, things are minimal more less demanding than some time recently, with php pre_match function i could extact Youtube Videos from url from any client post to utilize it independently without affecting the orginal post.


Youtube API is use to retrieve the content of the video 'http://www.youtube.com/embed/'
PHP preg_match function is used to check if youtube url format is detect to capture link address.

Meanwhile you have to define your width-height.

&lt;?php
$postdata ="THE SOCIAL NETWORK APP V.1.0 https://youtu.be/PGpbVQsVyRc Build Your Own Social Network"; // user post
 //if Youtube url detected;
if(preg_match('~(?:https?://)?(?:www.)?(?:youtube.com|youtu.be)/(?:watch\?v=)?([^\s]+)~', $postdata, $match)){
echo "
&lt;iframe width='560' height='315' src='http://www.youtube.com/embed/".$match[1]."' frameborder='0' allowfullscreen&gt;&lt;/iframe&gt;
";
//print ($match[1]); //url
}
else
{
echo $postdata;
}

?&gt;

9} How to extract Vimeo url from post


Vimeo is also one of the popular video straming website avaliable so far, and lots of people are diving into it to publish their story and content, is nice to share memorie with familie and friends. if you are a developer working on your dreamed project or client website, that need this feature, then this is the perfect code for you, light weight and small in 

&lt;?php
$message ="THE SOCIAL NETWORK APP V.1.0 https://vimeo.com/167653749 Build Your Own Social Network";
if(preg_match("/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/", $message, $output_array)) {
echo "&lt;br&gt;";

echo '&lt;br&gt;&lt;iframe width="600" height="400" src="//player.vimeo.com/video/'.$output_array[5].'?title=0&amp;amp;byline=0&amp;amp;portrait=0&amp;amp;color=ffffff" class="video"&gt;&lt;/iframe&gt;';

    //echo "Vimeo ID: $output_array[5]"; //url
    }

?&gt;

10} Instructions to separate @ and # symbol from string and how to change over text[url] to interactive connections


Creating clickable link with PHP is made easy, the function convert url to clickable link, this function support @ symbol and # tag enabled, for example like twitter or facebook @mention and hash # tag usage, you can implement this on your website or clients website. I have implemented this function On Thewallclone.com social system V3.0

&lt;?php
function clickable_links($message)
{
  $parsedMessage = preg_replace(array('/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\))+(?:\(([^\s()&lt;&gt;]+|(\([^\s()&lt;&gt;]+\)))*\)|[^\s`!()\[\]{};:\'".,&lt;&gt;?«»“”‘’]))/', '/(^|[^a-z0-9_])@([a-z0-9_]+)/i', '/(^|[^a-z0-9_])#([a-z0-9_]+)/i'), array('&lt;a href="$1" target="_blank"&gt;$1&lt;/a&gt;', '$1&lt;a href="http://thewallclone.com/$2"&gt;@$2&lt;/a&gt;',  '$1&lt;a target="_blank" href="http://thewallclone.com/search.php?s=$2&amp;searching=yes"&gt;#$2&lt;/a&gt;'), $message);
  return $parsedMessage;
}
echo clickable_links($message);
?&gt;

Trust postulations tips make a long keep running on your advancement profession... like, offer or hit me a remark simply say hello.... see you all around.