Carasoul / slider using PHP Function




In this tutorial , I shows you that how  to  be use a function in PHP smartly.

Suppose ,In  our website we have to use a carasoul or slider in many times or most of web pages, generally most new programmers write codes on each time. But if we use a functions , we have to write that codes in a single time . Every time we pass the parameter of function we get desire result as we want.




Let us see , Suppose this my web page. I use slider three times in my project.

slider-1-300x170

For that I write a single code for slider in a function file.Here is my function file.




In this function , I declare a function named get_slider , and pass parameters ($img1,$cap1,$img2,$cap2,$img3,$cap3) . Then in echo statement I design my slider using HTML and CSS.

After that I included that function file in my index.php file as like,

After body tag , I write

<?php echo get_slider(‘1.jpg’,’Title 1′,’2.jpg’,’Title 2′,’3.jpg’,’Title 3′);?>

this statement and generate a slider just passing the parameters in function. Each any everytime  I change only parameters of function but function name is same .

Finally, If we use function , we avoid code repeated and minimise the error.

Gaurav Sontakke on EmailGaurav Sontakke on FacebookGaurav Sontakke on Youtube
Gaurav Sontakke
Trainer at Orange Computer
My Self Gaurav Sontakke From Nanded having intrest from last 14 Yrs in RedHat Linux and Windows Server Configuration . Also in PHP MySql, Bootstrap, HTML, CSS, Javascript, Angular JS programming Language.
www.vinaycomputers.in is my official website.

Leave a Comment