Link Ads: Paket pembuatan website super murah dengan 200rb-an anda sudah punya website super cantik Start Your Own Facebook Network

Tag Archive | "php"

Fungsi Function PHP Dalam Mengolah Postingan


KampusKita.Us | Assalamaualaiku sohib kampuser ketemu lagi dengan postingan saya, setelah lama tidak sempat menulis lagi akibat disibukan dengan pekerjaan. Kali ini saya akan berbagi mengenai fungsi dalam web programing dengan bahasa PHP yang sering digunakan dalam mengolah postingan dalam cms buatan sendiri.

Untuk lebih jelasnya saya akan menjelaskan cara menampilkan data berupa text berupa auto paragrap, cara menampilkan cuplikan berita dan menghindari postingan yang berupa tag html / syntax php. Ok kita langsung saja ke pembahasannya:

1. Cara Menampilkan Auto Paragrap Dari SQL  (nl2br)

Bagi yang baru belajar membuat cms (termasuk saya :-) ) mungkin agak bingung jika menulis sebuah artikel dalam cms buatan sendiri jika kita ingin menampilkan auto paragrap. sebenarnya kita bisa menggunakan plugin Text Processing seperti FCKEditor, TinyMCE dan lain lain. Tapi biasanya bagi mahasiswa yang baru terjun ke dunia web programing mereka langsung menggunakan type input dengan type textarea. Dalam PHP ada sebuah fungsi dimana kita bisa membuat tulisan langsung auto paragram dengan menggunakan fungsi php

nl2br() [New Line To Break]

Nah fungsi ini bisa dijadikan alternatif jika anda tidak mau menuliskan tulisan dengan menyertakan tag html atau langsung menggunakan plugin text editor. Adapun prosedurnya seperti ini:

nl2br($parameter atau field databasenya)

contoh:

$koneksi=mysql_query(“SELECT * FROM artikel where idartikel=’$_GET[idartikel]‘ “);

$field=mysql_query_fetch_array($koneksi);

$tampilkan=nl2br($field[isi_artikel]);

echo $tampilkan;

Nah sintax nya seperti itu maka tulisan secara otomatis akan dibuat paragrap baru sesuai dengan tag enter (br) pada html. Jika masih bingung bandingan dengan $tampilkan=$field[isi_artikel]; dengan $tampilkan=nl2br($field[isi_artikel]);

2. Cara Menampilkan Cuplikan Berita Ala WordPress (substr)

Keren kan jika cms kita bisa kaya  tampilan wordpress? hm..ternyata selain fungsi explode ada fungsi yang menurut saya paling mudah, yaitu dengan fungsi substr() / substring fungsi ini akan membaca dari string 0 sampai batas string yang kita tentukan syntaxnya seperti berikut:

substr($field, awal_string, batas_string);

Penjelasan:

$field = Ini bisa diisi dengan string langsung atau berupa field database.

awal_string = Awal pembacaan string untuk ditampilkan biasanya diseting ke 0 (nol).

batas_string = Batas kata / karakter yang akan ditampilkan.

Contoh anda akan menampilkan artikel yang berkarakter 1000 tapi anda ingin yang ditampilkan hanya cuplikan saja 100. Note: fungsi ini biasa dipakai untuk artikel by kategori atau lates artikel.

$tampilkan=substr($field[isi_artikel], 0, 100);

echo $tampilkan;

3. Cara Menghindari Deface Guestbook (htmlspecialchars)

Mahasiswa yang bisa membuat guestbook / buku tamu dalam cms buatanya jangan bangga dulu, jika karya anda sudah online biasanya guestbook jadi sasaran empuk para spamer celakanya mereka sering menginput dengan menggunakan tag html / bbcode / code php secara langsung. Nah untuk menghindari hal itu kita bisa menggunakan fungsi htmlspecialchars().

htmlspecialchars adalah fungsi mengubah tag html ke karakter khusus yang sesuai dengan isinya. syntaqknya seperti dibawah ini.

htmlspecialchars($variable);

contoh:

$pesan_buku_tamu=$_POST[pesan];

$simpan=mysql_query(“INSERT INTO buku_tamu (isi_pesan) VALUES (“‘$pesan_buku_tamu’”);

if($simpan) {

echo ‘Data berhasil disimpan’  ; }

else {

echo ‘Gagal’;  }

$tampil=mysql_query(“SELECT * FROM buku_tamu”);

while($field=mysql_query_fetch_array($tampil))

$asli=htmlspecialchars($field[isi_pesan]);

{

echo $asli; }

Jadi dengan menggunakan fungsi htmlspecialshars() data akan ditampilkan apa adanya sesuai dengan apa yang diketik di form isian Buku Tamu.

Nah sekian dulu tips sederhana dari saya mudah mudahan bermanfaat jangan lupa jika ada kesalahan mohon maaf, dan anda bisa berkomentar untuk membetulkan dan memberi solusi lainya.

Posted in PHPComments (0)

Web server super ringan !


Setelah memakai IIS yang bikin Kompis ngeden, Pake Apache yang selalu bentrok akhirnya ku bantai itu semua server. Saya nemunin dan nyobain namanya server NGINX ya NGINX adalah web server yang bisa digunakan untuk PHP dan ukuran file nya hanya 1 MB, tanpa perlu install tingal ekstrak dan double klik file NGINX.EXE nya secara otomatis http://localhost bisa diakses. Untuk penyimpanan filennya simpan aja di folder html dalam folder ekstrakan NGINX.

Jika butuh referensi baca aja disini :

http://wiki.nginx.org/

Nginx is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Igor Sysoev started development of Nginx in 2002, with the first public release in 2004. Nginx now hosts nearly 7.65% (22.8M) of all domains worldwide.

Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

Nginx is one of a handful of servers written to address the C10K problem. Unlike traditional servers, Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.
Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from Nginx’s high-performance and small memory footprint. Nginx scales in all directions: from the smallest VPS all the way up to clusters of servers.

Nginx powers several high-visibility sites, such as WordPress, Hulu, Github, Ohloh, SourceForge and TorrentReactor.

Posted in Web Server, Web TutorialsComments (0)

Make web with domain name in your like free


Professional Grade Web Server Software

WampDeveloper v4 is the cumulative knowledge of our 7+ years of website development & hosting experience merged into 1 software product. It literally transforms the way you work.

We’ve gathered the entire Apache, PHP, and MySQL platform into 1 easy-to-use application that manages and self-hosts websites for you, removed of all complexity.

With WampDeveloper you get a full webserver platform (and user interface) that is ready-to-run on your PC, Server, and Laptop without any further setup, configuration, or installations.

Did you know that WampDeveloper can:

  • Host multiple websites on a single IP address: from home, office, or datacenter. Including SSL websites.
  • Automatically install WordPress, Drupal, Joomla, Magento, phpBB3, and MediaWiki for you on any website and URL.
  • Integrate with Tomcat and IIS running on the same system … so in addition to PHP, you can also run Java/JSP and ASP.NET code.
  • Provides phpMyAdmin interface to the MySQL Database, and AWStats log analysis / per website.
  • Dramatically increase PHP performance by using PHP Opcode Cache (eAccelerator).
  • Switch between all provided versions of Apache, PHP, and MySQL with 1 click.

Whats new in version 4?

WampDeveloper Pro v4 has been completely re-engineered from the ground up. The biggest changes are:

  • The User Interface is now a first class application that controls every aspect of WampDeveloper.
  • Everything is now automated for you… To create a website: input the domain name and WampDeveloper will create all the folders, virtual hosts, configuration files, set up local DNS, etc.
  • Apache, PHP, MySQL versions can be selected with a click and are kept up-to-date… Just use the User Interface to select which versions you would like, click update, and WampDeveloper will re-link the structure of the Components folder to point to the selected versions.
  • PHP Opcode Cache is included.
  • The folder structure has been redone to increase modularity, ease of use, and make upgrades and backups simple.

For Website Development

Everything you need to get started building websites is included!

  • Quick and Easy Setup – WampDeveloper installs in less than 60 seconds, and is self-contained.
  • Website Creation – Websites are created with 1 click and will imidiatly be viewable in your browser (IE, Firefox, Chrome, Opera).
  • Web Applications Installer – WampDeveloper can install Drupal, Joomla, WordPress, MediaWiki, phpBB3, and Magento into any website and URL for you.
  • Local DNS Settings – WampDeveloper can also work with non-registered and non-resolving (fictional) domain names.
  • Simple to Reinstall – There are no limits on how many times you can uninstall and then re-install WampDeveloper.

For Hosting Websites

We’ve done all the hard work for you!

  • Unlimited Websites – With a single IP address, WampDeveloper will host unlimited HTTP and SSL websites.
  • Performance Optimzed – A maximum performance configuration designed to handle hundreds of concurrent connections, in combination with PHP Opcode and MySQL Query cache, results in performance gains of 5-10x (over a standard Apache Server).
  • Traffic Compression – Our traffic compression configuration can reduce bandwidth by 75% and significantly decrease page load time.
  • Useful Licensing – WampDeveloper allows you to run 3 copies: 1 Production (Deployment) + 1 Development (Testing) + 1 Standby (Failover).
  • Expert Support – We’re here to answer your questions and troubleshoot your issues. Support is not outsourced and is always provided by an experienced WampDeveloper engineer.

 

Posted in Web Server, Web TutorialsComments (0)

Advert

Like Us Sponsor

Our Friends



Adsense Indonesia