Category : coding

how to get number of days in the month with php

In : calendar, coding, date, function, month, parameter, php, Posted by wahyupramusinto on Jan.01, 2009

Comments Off

if you want to know number of days in the month with php, you can call function cal_days_in_month()
this function returns the number of days in a given month, based on the calendar, month, and year that you specify

the format of this function is
Cal_days_in_month (calendar, Month, year)
This function have three parameters,

  • calendar, you can fill this parameter with CAL_GREGORIAN
  • month, you can fill this parameter with month (1 – 12)
  • year, you can fiil this parameter with 4 digits of year (2008)

example :
$days = cal_days_in_month(CAL_GREGORIAN, 1, 2009) ;
echo “In January 2009 there were $days days”;
?>

that example will display
In january 2009 there were 31 days



Javascript Explode Implode

In : coding, explode, html, implode, javascript, php, script, split, tutorial, web, Posted by wahyupramusinto on Feb.02, 2008

Comments Off

JavaScript equivalent of PHP explode function

In PHP we can easily break a long string into smaller parts by using the explode() function of PHP. In run rime, this function works like this:

$string=”My Name Is Wahyu Pramusinto”;
$string2=explode(” “, $string);

After the execution of the second command the variable $string2 is an array such that,

$string2[0]=”My”
$string2[1]=”Name”
$string2[2]=”Is”
$string2[3]=”Wahyu”
$string2[4]=”Pramusinto”

and so on. So how do we do it in JavaScript. In JavaScript there is a split() function that achieves the same objective, although the syntax is a bit different.

var string=”My Name Is Wahyu Pramusinto”;
var string2=string.split(” “);

Now the variable string2 has all those words.





Introduction CakePHP

In : cake, cakephp, code, coding, framework, php, programming, Posted by wahyupramusinto on Jan.01, 2008

Comments Off

Introduction to CakePHP
Section 1
What is CakePHP?

CakePHP is a free open-source rapid development framework for PHP. Its a structure of libraries, classes and run-time infrastructure for programmers creating web applications originally inspired by the Ruby on Rails framework. Our primary goal is to enable you to work in a structured and rapid manner – without loss of flexibility.
Section 2
Why CakePHP?

CakePHP has several features that make it a great choice as a framework for developing applications swiftly and with the least amount of hassle. Here are a few in no particular order:

1.

Active, friendly community
2.

Flexible Licensing
3.

Compatibility with PHP4 and PHP5
4.

Integrated CRUD for database interaction and simplified queries
5.

Application Scaffolding
6.

Model View Controller (MVC) Architecture
7.

Request dispatcher with good looking, custom URLs
8.

Built-in Validation
9.

Fast and flexible templating (PHP syntax, with helpers)
10.

View Helpers for AJAX, Javascript, HTML Forms and more
11.

Security, Session, and Request Handling Components
12.

Flexible access control lists
13.

Data Sanitization
14.

Flexible View Caching
15.

Works from any web site subdirectory, with little to no Apache configuration involved

Section 3
History of CakePHP

In 2005, Michal Tatarynowicz wrote a minimal version of a Rapid Application Framework in PHP. He found that it was the start of a very good framework. Michal published the framework under the MIT license, dubbing it Cake, and opened it up to a community of developers, who now maintain Cake under the name CakePHP.
print chapter

source : http://manual.cakephp.org/chapter/intro, ajax