CS Knowledge Opener - Logo
CS Knowledge
Opener
Facebook Youtube Telegram
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
CS Knowledge Opener - Logo
CS Knowledge
Opener
Facebook Youtube Telegram
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
  • Home
  • 12th CS
    • 12th CS English Medium
    • 12th CS Tamil Medium
  • 12th CA
    • 12th CA English Medium
    • 12th CA Tamil Medium
  • 11th CS
    • 11th CS English Medium
    • 11th CS Tamil Medium
  • 11th CA
    • 11th CA English Medium
    • 11th CA Tamil Medium
  • CS / CA Question Bank
  • Other Subjects
  • Student Alerts
  • Govt Exams
12th CA English Medium

Practical program exercise 6 PHP Basic Programing for 12th computer applications

Baskaran J
February 13, 2023 2 Mins Read
2.4K Views
0 Comments

PHP Basic Programing

Ternary operator

  • Ternary operator is also known as conditional operator that evaluate something based on a condition being true or false.
  • It simply allows testing a condition in a single line replacing the multiline if-else making the code compact.

Functions:

  • A function is that they are reusable; if you have a task that needs to be performed a number of times, a function is an ideal solution.

SYNTAX:

function functionName()
{
Custom Logic code to be executed;
}

  • A user-defined Function declaration begins with the keyword “function”. User can write any custom logic inside the function block.

Concatenation

  • Two operators are used to perform string related operations such as Concatenation
  • $text1 . $ text2

Basic Rules for Variable Declaration

  • Variable name must always begin with a $ symbol.
  • Variable name can never start with a number.
  • Variable names are case-sensitive.

Embed PHP in HTML

  • PHP script can be written in side the HTML code and save the file with extension of .php.
  • The embedded PHP file get executed in the Webserver, the browser receives only the HTML and other client side files.

PHP

  • PHP is one of the most widely used and recognizable technologies in use on the internet.
  • Originally PHP stood for “Personal Home Page”, though more recently it has been changed to stand for “PHP: Hypertext Preprocessor”.

CA – 6 PHP – BASIC PROGRAMING

QUESTION:

Write a PHP code to display the given number is either greater than 30 or 20 or 10 using function with ternary operator.

AIM:

To create and execute a basic PHP programming

PROCEDURE:

  1. Start Xampp server (Apache)
  2. Go to virtual path folder (C:\xampp\htdocs)
  3. Create test.php file and type the program
  4. Execute the program on your Web browser using by this URL link (http://localhost/test.php)

PROGRAM:

<html>

<body>

<?php

echo “Welcome to Our School <br>”;

$color = “blue”;

echo “My car is $color  <br>”;

echo “My dress is $COLOR <br>”;

echo “My box is $coLOR <br>”;

function trinary_Test($n)

{

$r = $n > 30

? “greater than 30<br>”

: ($n > 20

? “greater than 20<br>”

: ($n >10

? “greater than 10<br>”

: “Input a number atleast greater than 10!<br>”));

echo $n.” : “.$r.”\n”;

}

trinary_Test(32);

trinary_Test(21);

trinary_Test(12);

trinary_Test(4);

?>

</body>

</html>

OUTPUT:

Welcome to Our School
My car is blue
32 : greater than 30
21 : greater than 20
12 : greater than 10
4 : Input a number atleast greater than 10!

RESULT:

The Output was verified successfully

 

Tags:

Practical

Share Article

Follow Me Written By

Baskaran J

Other Articles

Previous

Model question paper for 12th computer science 2023

Next

Practical program exercise 7 PHP Create & Execute Variables for 12th computer applications

Next
February 15, 2023

Practical program exercise 7 PHP Create & Execute Variables for 12th computer applications

Previous
February 11, 2023

Model question paper for 12th computer science 2023

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

19 − eight =

Related Posts

12th CA Board Exam Answer Key Discussion 2024-2025

Baskaran J
March 14, 2025

12th Computer Applications English medium Program Question 2024-2025

Baskaran J
February 23, 2025

12th Computer Applications Practice One marks question 2024-2025

Baskaran J
February 3, 2025

12th Computer Applications English medium Public Exam Important Question 2024-2025

Baskaran J
January 16, 2025

Subscribe to our newsletter and stay updated.

CS Knowledge Opener

CS Knowledge Opener focuses on 11th &12th Computer Science & Computer Applications English Medium & Tamil Medium. Programming Skills and also we are Publishing Study Materials Based on New syllabus introduced by TNSCERT. (TNBOARD).

Quick Links

  • Contact Us
  • About Us
  • Privacy Policy
  • Disclaimer
  • Terms and Conditions
Categories
11th CA English Medium 15
11th CA Tamil Medium 9
11th CS English Medium 21
11th CS Tamil Medium 12
12th CA English Medium 32
12th CA Tamil Medium 8
12th CS English Medium 36
12th CS Tamil Medium 12
Government Exams 36
Notifications 8
Other Subjects 13

Follow Us

Youtube
Facebook
Telegram
CS Knowledge Opener © 2020 - 2025. All Rights Reserved.