Simple fibonacci with php

  $a=0;
  $b=1;
  $c=0;
  echo ("$a\n");
  echo ("$b\n");
  for ($i=0;$i<=17;$i++){
    $c=$a+$b;
    $a=$b;$b=$c;
    echo ("$c\n");
  }
Result:
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

wikipedia, how it works.

send SMS with php


Simpels developed a class for sending sms, but remember, it’ll only funcinonar depending on the operator’s response is not only to test and find that it will work, has a number of rules of the carrier to make it work, but if you need to a project, your company will probably contact the operator and make some sort of contract for use.

I will make available for download codes in the “Free Codes”

Here the simple code.
First, let’s put the class.

	class smsClass {
		public $messages;
		public $from;
		public $carriers;
		public $tryall;

		function __construct($dotry = false){
			$this->carriers = array(
				'att' => 'txt.att.net',
				'claro' => 'clarotorpedo.com.br',
				'nextel' => 'messaging.nextel.com',
				'vivo' => 'torpedoemail.com.br',
				'orange' => 'orange.net'
			);
			$this->tryall = $dotry;
		}

		function message($carrier, $phone, $message) {
			if($phone == '') {
				return FALSE;
			} else if($message == '' || strlen($message) > 140) {
				return FALSE;
			} else if($carrier == '' || !$carrier) {
				if($this->tryall == TRUE) {
					foreach($this->carriers as $carriername => $carrierconnection) {
						$this->messages[] = array($carriername, $phone, $message);
					}
					return TRUE;
				} else {
					return FALSE;
				}
			} else {
				$this->messages[] = array($carrier, $phone, $message);
				return TRUE;
			}
		}

		function send_messages() {
			foreach($this->messages as $message) {
				$carrier = $this->carriers[strtolower(str_replace(array('&', '-', '_'), '', $message[0]))];
				$phone = strtolower(str_replace(array('+', '_', '-'), '', $message[1]));
				$send = $phone . '@' . $carrier;
				$message = $message[2];
				mail($send, null, $message, 'From: ' . $this->from);
			}
			$this->messages = array();
		}

		function from($from){
			$this->from = $from;
		}

	}

Now the page where you make the setting for the shipment.

  require_once("smsClass.php");
	$sms = new smsClass();
	$sms->from('support@domain.com');
	$status = $sms->message('carrie', 'number', 'message');
	$sms->send_messages();

The importance of using DEFINE in their projects

The use of DEFINE is important for several things, for example:
Sites with more than one language.
Set the system default url.
Url Set the root system.

Finally, a number of things we need and always do the worst possible sites using “. / Or ../’.
Anyway, do not need this anymore, if for example, define the default url of the site will be as follows:

define ('URL_SITE', "http://localhost/your_project/", true);

Using true you can use your definition in upper or lower case without it, an error will be displayed.

For a system with more than one language or even a language.
in your file name, e.g: eng.php

define ('LABEL_TEST', 'Label example ", true);

and
in your file name, e.g: pt_BR.php

define ('LABEL_TEST', "Sample Label", true);

And in your code you only print your label, so

echo LABEL_TEST

it is easier to have a system with several languages.

Pretty soon, if your system needs to login to be accessed, causes the user to choose a language on edit account, just remember to always leave a default language, you do not need login, you need to use cookies, this is a problem because it has users that do not allow cookies on their computers, you can consider it a problem or not, consider, advise the user that he must allow cookies in your browser, if not a problem, fuck it lol.

But anyway, this method is widely used, already used for some years, and today it decided to make a comment.

I hope you make good use of it in their projects.

How to Highlight quotes with coffeescript

Hello, I’ll show you how easy it is to highlight a word in a search using coffeescript, and then I will show the difference in the coffee and use jquery normal, and in the end, the result compiled coffeescript.
The code is much more organized and beautiful.

To call the function Search  do as follows:

any_name = new Search();

any_name=highlight(“your param or quote”);

in Rails: any_name=highlight(“<%= params[:search] %>”);
in PHP: any_name=highlight(“<?php echo $_POST["search"]?>”); OR any_name=highlight(“<?php echo $_GET["search"]?>”);

Using CoffeeScript.

Using jQuery

 

Result Compiled of CoffeeScript

 

CoffeeScript code download here.

jQuery vs Flash

Hi, this is a simple example that it is possible to create animated applications using jquery and not flash.

This was a wedding gift from a friend of mine.

Roberta & Gustavo