Search
 
SCRIPT & CODE EXAMPLE
 

PHP

javascript inside php

<?php
  FONCTION_PHP(){
  ?>
   <script>
    function fonctionJavaScript(){
  }
    </script>
<?php
	}
  ?>
Comment

how to write javascript inside php

//this is my code 

you can add javascript to your code by using the echo statement and rap all 
your javascript between "" and if there is "" in the javascript code
then add  before any "", and for the php inside rap it with ''
  
  
<?php
  echo "<script>document.write("hello world")</script>"
?>
  
//other example

<?php
  $a = 5;
  echo "<script>document.write('$a')</script>"
?>

//other example
  
<?php 
$TokenData = Auth::user();

echo "<script type="text/javascript">
             localStorage.setItem("id", '$TokenData->id');
             localStorage.setItem("name", '$TokenData->name');
             localStorage.setItem("email", '$TokenData->email');
      </script> ";
Comment

PREVIOUS NEXT
Code Example
Php :: set unique value validation for laravel form request 
Php :: php absolute value 
Php :: sending data from one website to another in php 
Php :: php back to original site 
Php :: mysql secure 
Php :: localhost didn’t send any data 
Php :: php end session 
Php :: check if string starts with php 
Php :: laravel db ssh 
Php :: validator and custom error laravel 8 
Php :: implode and explode in php 
Php :: left join laravel 
Php :: laravel collection sum array column 
Php :: Clear from faild_jobs laravel 
Php :: insert data using mysqli in php 
Php :: eloquent with select 
Php :: php hash 
Php :: PHP validation/regex for URL 
Php :: Fatal error: Exception thrown without a stack frame in Unknown on line php 
Php :: keep only n elements of array php 
Php :: move post to draft php wordpress 
Php :: how to set base url in codeigniter 
Php :: contact form 7 remove p 
Php :: laravel nested query builder 
Php :: laravel assets path 
Php :: ternary operator for three conditions in php 
Php :: arrow function in php 
Php :: php string to uppercase 
Php :: laravel route target class not found 
Php :: laravel spatie asigne role 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =