Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How can you convert these JavaScript functions to a PHP class to be inserted into a .php file? //Constructor for the Question function Question(category,question,answers){ //How

How can you convert these JavaScript functions to a PHP class to be inserted into a .php file?

//Constructor for the Question function Question(category,question,answers){ //How many arguments are provided var nArgs=arguments.length;//The number of arguments passed to the function if(nArgs==0||nArgs>3){//Empty Question this.cat=""; this.qstn=""; }else if(nArgs==3){//Question provided with all inputs this.cat=category; this.qstn=question; this.ans=answers; }else if(nArgs==2){//Question provided with no answers added latter this.cat=category; this.qstn=question; }else{ this.cat=category.cat; this.qstn=category.qstn; this.ans=category.ans; } }; //Setting the Category Question.prototype.setCat=function(category){ this.cat=category; }; //Setting the Question Question.prototype.setQstn=function(question){ this.qstn=question; }; //Adding an Answer Question.prototype.addAns=function(answer){ this.ans.push(answer); }; //Accessing the Category Question.prototype.getCat=function(){ return this.cat; }; //Accessing the Question Question.prototype.getQstn=function(){ return this.qstn; }; //Accessing one of the Answers Question.prototype.getAns=function(number){ if(number>=0&&number"+this.qstn+"

"); for(var i=0;i0) document.write('

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+j Enabling a productive global workforce.

Answered: 1 week ago

Question

=+ Are you interested in creating or

Answered: 1 week ago

Question

=+working on a micro-multinational?

Answered: 1 week ago