Tag

php tutorials

Browsing

Share Your Website Post To Social Media using php

Share Your Website Post To Social Media using php

Share your website post to social media using php. Everyone want to share their post in social media regularly to get increase the page views and also website view. So the social media is the best way to promote our content to reach everyone. When ever we write our post we directly update this post into our social media using php

Here I am written sharing code, Just click social media icons it will share automatically to your social media timeline

Here I have get our website details description and content using php

<?php $url="https://www.developerdesks.com/";
$name="Share post links articles to social network with Yoursite"; 
$caption="social sharing developer desks"; 
$description="Write some fo the description about your content."; 
$logo="https://www.developerdesks.com/logo.png"; ?>

Here we going to add Facebook and Google plus sharing

<html>
<head>
<title>Share links | Developerdesks</title>
</head>
<body>
<div class="gplus">
<!--google+ sharing --> 
<a href="https://plus.google.com/share?url={<?php echo $url;?>}" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
<img width="200" src="google+.png"/> </a> 
</div>
<!--/google+ sharing --> 
<div class=""fb-class">
<!-- fb sharing -->
<a href="#" id="shareonfacebook"><img src="facebook.jpg"></a>
<div class="fb-share-button" data-href="<?php echo $url; ?>" data-layout="button_count">
</div></a>
</div> </body> </html>

Add Javascript for sharing link
Het your facebook api id from the developers facebook page

Find how to get app id – Here

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script> $(document).ready(function () { $('#shareonfacebook').click(function (e) {  var name ='<?php echo $name; ?>'; var caption ='<?php echo $caption; ?>'; var picture ='<?php echo $picture; ?>'; var description ='<?php echo $description; ?>'; var link ='<?php echo $url; ?>';  e.preventDefault(); FB.ui( { method: 'feed', name: name, link: link, caption: caption, picture: picture, description: description, message: '' }); }); });  </script> <script> FB.init({appId: 'yourappid', status: true, cookie: true, xfbml: true}); </script> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=yourid&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script>

Here we added the javascript for post article. now you can used ur post to share in social media

Simple JavaScript Calculator code with example

Here we going to learn simple javascript calculator code. Generally for beginners, they think its difficult to writing code for calculator. But its not that much difficult in the codding.
We just know only simple things in function like add, sub, mutli and div functions in php. If you know that then the calci code is very simple, you may try it now
javascript calculator code

Step 1:
First create html file

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Simple JavaScript Calculator</title>

</head>
 
<body>
<h2>Simple JavaScript Calculator</h2>
 
<form name="calcForm">
<table>
<tr>
  <td colspan="4"><input type="text" name="display"
                         style="text-align:right"></td>
</tr>
<tr>
  <td><input type="button" name="btn1" value="1"
             onclick="calcForm.display.value += '1'"></td>
  <td><input type="button" name="btn2" value="2"
             onclick="calcForm.display.value += '2'"></td>
  <td><input type="button" name="btn3" value="3"
             onclick="calcForm.display.value += '3'"></td>
  <td><input type="button" name="btnAdd" value="+"
             onclick="calcForm.display.value += ' + '"></td>
</tr>
<tr>
  <td><input type="button" name="btn4" value="4"
             onclick="calcForm.display.value += '4'"></td>
  <td><input type="button" name="btn5" value="5"
             onclick="calcForm.display.value += '5'"></td>
  <td><input type="button" name="btn6" value="6"
             onclick="calcForm.display.value += '6'"></td>
  <td><input type="button" name="btnSub" value="-"
             onclick="calcForm.display.value += ' - '"></td>
</tr>
<tr>
  <td><input type="button" name="btn7" value="7"
             onclick="calcForm.display.value += '7'"></td>
  <td><input type="button" name="btn8" value="8"
             onclick="calcForm.display.value += '8'"></td>
  <td><input type="button" name="btn9" value="9"
             onclick="calcForm.display.value += '9'"></td>
  <td><input type="button" name="btnMul" value="x"
             onclick="calcForm.display.value += ' * '"></td>
</tr>
<tr>
  <td><input type="button" name="btnClear"
             value="C" onclick="calcForm.display.value = ''"></td>
  <td><input type="button" name="btn0" value="0"
             onclick="calcForm.display.value += '0'"></td>
  <td><input type="button" name="btnEqual" value="="
             onclick="calcForm.display.value = eval(calcForm.display.value)"></td>
  <td><input type="button" name="btnDiv" value="/"
             onclick="calcForm.display.value += ' / '"></td>
</tr>
</table>
</form>
 
</body>
</html>

Step 2: Add Css file for the page

input {
       font-family: consola, monospace;
       color: blue;
     }
     td {
       margin-left: auto;
       margin-right: auto;
       text-align: center;
     }
     table {
       border: thick solid;
     }

Step 3: Add javascript for the calci function.

window.onload = initClock;
 
function initClock() {
  var now = new Date();
  var hr  = now.getHours();
  var min = now.getMinutes();
  var sec = now.getSeconds();
  if (min < 10) min = "0" + min;  // insert a leading zero
  if (sec < 10) sec = "0" + sec;
  document.getElementById('clockDisplay').innerHTML
        = "Time is " + hr + ":" + min + ":" + sec;
  setTimeout('initClock()', 500);
}

Here the Demo –

See the Pen KpvNZR by Rajaseka G (@SekarG) on CodePen.

Php Introduction

PHP Introduction

Before learning php, you should have some knowledge in below topics:

  • HTML
  • CSS
  • JavaScript

Define php?

  • PHP is an acronym for “Hypertext Preprocessor”
  • PHP is a widely-used, open source scripting language
  • PHP scripts are executed on the server
  • PHP costs nothing, it is free to download and use

Php File

  • PHP files can contain text, HTML, CSS, JavaScript, and PHP code
  • PHP code are executed on the server, and the result is returned to the browser as plain HTML
  • PHP files have extension “.php”

Thats basic intro about PHP