Category : php

Unlike var_dump or var_export the function print_r seems to display blanks instead of words like NULL and false: <?php $arr = array(‘one’ => true, ‘zero’ => false, ‘null’ => null, ‘recursive’ => array(1=>array(2=>3))); echo ‘<pre>’ . print_r($arr, true) . ‘</pre>’; // Array echo ‘<pre>’ . var_export($arr, true) . ‘</pre>’; // String => gettype(var_export($arr)); returns string ..

Read more

I do not know why this cannot work. It can output a button element but the onclick function cannot work at all. Not even an alert box pop up. PLS help. <!DOCTYPE html> <html> <body> <?php $name = "John"; echo "<button type=’button’ onclick=’callYou(‘".$name."’)’> click me </button>"; ?> <script> function callYou(name) { if(confirm("Are you sure?")) { ..

Read more

I have a livesearch where the titles from my XML file show when typing. I need to add more tags which can be searched for and show as results. I wonder if I can add more sources to this code: <?php $xmlDoc=new DOMDocument(); $xmlDoc->load("links.xml"); $x=$xmlDoc->getElementsByTagName(‘link’); //get the q parameter from URL $q=$_GET["q"]; //lookup all links ..

Read more

Here is the event: class AssetsInfo implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; public $actionId; public $actionData; public function __construct($actionId, $actionData) { $this->actionId = $actionId; $this->actionData = $actionData; } public function broadcastOn() { return new Channel(‘sahmshenas-channel’); } public function broadcastWith() { return [ ‘actionId’ => $this->actionId, ‘actionData’ => $this->actionData, ]; } public function broadcastAs(){ return ..

Read more

I’m trying to utilize laravel passport for api authentication $user = User::create([ ‘first_name’ => $request->firstName, ‘last_name’ => $request->lastName, ’email’ => $request->email, ‘password’ => Hash::make($request->password), ‘verified’ => User::UNVERIFIED_USER, ‘capacity’ => User::REGULAR, ‘verification_token’ => User::generateVerificationToken(), ]); $token = $user->createToken(‘Laravel Password Grant Client’)->accessToken; return response()->json([‘data’ => $token]); and I’m getting this error: "message": "Method LaravelPassportBridgeAccessToken::__toString() must not throw ..

Read more