[Solved] OO PHP, class function variable [closed]

The code will go like this:- List.php class listPage { public $category; function __construct() { $this->category = ”; } function setCategory($value) { $this->category=$value; echo $this->category; } } Controller.php $start = new listPage(); $start->setCategory(3); 0 solved OO PHP, class function variable [closed]

[Solved] Outputting form result [closed]

Keeping things simple here… You will need 2 files. A file with your form, and a file to handle your form. form.php <form action=”submit.php” method=”post”> <select name=”gender”> <option value=””> Choose Gender </select> <option value=”Female”>Female</option> <option value=”Male”>Male</option> </select> <input type=”submit” value=”Submit” /> </form> submit.php <?php $gender = $_POST[‘gender’]; // grab other input values in the same … Read more

[Solved] Acessing php variable using jquery [closed]

If the side is being processed through PHP (on the server) you can just use an echo <pre> <script> $(document).ready(function(){ var timeLeft = <?php echo 12796; ?>; console.log(timeLeft); }); </script> After PHP has processed the page it is just regular javascript as if you wrote it manually. You can also imagine the following example: <html> … Read more

[Solved] Getting the id and values of a textbox [closed]

$(document).ready(function(){ $(‘input#receive’).click(function(){ $(‘input[type=text]’).each(function() { var input_value = $(this).val(); var input_id = $(this).attr(‘id’); alert(‘Value: ‘ + input_value + ‘, ID: ‘ + input_id); }); }); }); 1 solved Getting the id and values of a textbox [closed]

[Solved] what is it that i am doing wrong while converting [closed]

prepare() goes with execute() Prepared statements basically work like this: Prepare: An SQL statement template is created and sent to the database. Certain values are left unspecified, called parameters (labeled “?”). Example: INSERT INTO mtTable VALUES(?, ?, ?) The database parses, compiles, and performs query optimization on the SQL statement template, and stores the result … Read more

[Solved] Why do we need specific classes to work with Request and Response?

As mentioned here : The Request class is an object-oriented representation of the HTTP request message. With it, you have all the request information at your fingertips and As a bonus, the Request class does a lot of work in the background that you’ll never need to worry about. For example, the isSecure() method checks … Read more

[Solved] select 40 words from a string

Assuming words would be separated by spaces. $words40=explode(” “, $string,41); unset($words40[40]); // Discard the last element containing the remaining string Of course this will fail on punctuation marks, but since you did not mention whether your string contains something to do with human readable languages or any other value, there is no reason to assume … Read more

[Solved] How to declare an associative array in PHP using array()? [closed]

To assign values to array with keys. You can simply write: $files = array(); $files[‘some_key’] = ‘an important value’; $files[‘another_key’] = ‘a value’; $files[‘key’] = ‘an non-important value’; Output: Array ( [some_key] => an important value [another_key] => a value [key] => an non-important value ) You can also just create an array by simply … Read more

[Solved] Group array by inner value in PHP

Try this $result = []; foreach ($array as $vlaue) { $uniqueKey = $vlaue[‘lat’] .’_’. $vlaue[‘long’]; $result[$uniqueKey][] = $value; } $result = array_values($result); 2 solved Group array by inner value in PHP

[Solved] Error in the exercise of oop [closed]

It is because there is no constructor in the Conta class. Because, in the child class ContaPoupanca, you called the constructor of the parent class which is Conta like this: parent::__construct($Agencia, $Codigo, $DataCriacao, $Titular, $Senha, $Saldo); Therefore, to make this work, the parent class Conta should have a constructor like this: public function __construct($Agencia, $Codigo, … Read more

[Solved] php regex preg_replace html tags

It would better to use a library like DOMDocument to parse the HTML. But if you really have to do it with a regexp…. Don’t use | in the regexp, that matches either class or id, but not both. preg_replace(‘~<div\b.*?\bclass\s*=\s*”(.*?)”.*?\bid\s*=\s*”(.*?)”.*>~i’,'<div class=”$1″ id=”$2″>’, $content); Note that this will only work if the class is to the … Read more

[Solved] How Can i pass multiple parameter dynamically get request to check whether fbtoken is valid or not

you get that error because you are not properly urlencoding the variables you insert into the url. use urlencode() or http_build_query(), eg $url=”https://graph.facebook.com/debug_token?” . http_build_query ( array ( ‘input_token’ => $fb_token, ‘access_token’ => $access_token ) ); or $url=”https://graph.facebook.com/debug_token?input_token=” . urlencode ( $fb_token ) . “&access_token=” . urlencode ( $access_token ); and it will be properly … Read more

[Solved] How to add sub string to each element in a string seperated by comma

I guess the quickest fix would be preg_replace? This should work: $str = preg_replace(“https://stackoverflow.com/”([0-9]{1})/”,”‘000\\1″,$str); It is replacing every instance of a single quote followed by 1 number with a single-quote, then 3 zeros and then the number we matched solved How to add sub string to each element in a string seperated by comma

[Solved] Create three function to call Today, Yester and Future in PHP [closed]

You can use these function : // midnight second or equal today function isToday($time) { return (strtotime($time) === strtotime(‘today’)); } //Yesterday function isPast($time) { return (strtotime($time) < time()); } // Next day function isFuture($time) { return (strtotime($time) > time()); } 2 solved Create three function to call Today, Yester and Future in PHP [closed]

[Solved] How to curl via php [closed]

You should try to do something from your side and mention it on the question. Anyways here’s the solution for your problem <?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => ‘https://api.mydomain.in/api/comm/wa/send/text’, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => ”, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => ‘POST’, CURLOPT_POSTFIELDS =>'{ “phone”: … Read more