Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Connect JS file in php

// simply add this to your head tag or top of your page.
<script src="myscripts.js"></script>
Comment

how to add javascript to a php file

//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

how to include javascript in php

// simply echo the path anywehre in php you need

echo "<script src="script.js" type="text/javascript"></script>"
Comment

PREVIOUS NEXT
Code Example
Php :: laravel wherenotin 
Php :: laravel global scope 
Php :: php intval 
Php :: using PDO and PHP = Login.php 
Php :: how to make zip in php by multiple files 
Php :: laravel 7 eloquent on delete set null schema 
Php :: how to remove annoying plugin notification in wordpress 
Php :: php extract month and year from date 
Php :: get ip address of client php 
Php :: how to check user already exists in php 
Php :: http_response_code 
Php :: laravel 5 use env variable in blade 
Php :: php return function result to variable 
Php :: laravel hasMany with join 
Php :: php geolocation package 
Php :: image upload in laravel 
Php :: find over array object php find 
Php :: whereHas site:https://laravel.com/docs/ 
Php :: cviebrock/eloquent-sluggable 
Php :: file upload permission in php 
Php :: time function in php 
Php :: php session variables 
Php :: Copy file from one directory to another Laravel 
Php :: double where condition in laravel 
Php :: print in php 
Php :: woocommerce php product gallery change to carousel 
Php :: new DateInterval 1 hour 
Php :: update profile method in laravel 
Php :: taxonomy_get_parents drupal 8 
Php :: laravel collection merge 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =