Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
38 views

PHP and Javascript Summary

The document describes various HTML elements and their attributes including images, links, lists, forms, tables, and JavaScript functions and events. It provides details on how to use common HTML elements like <img>, <a>, <ul>, <form>, and <table>. It also summarizes JavaScript concepts like loops, functions, arrays, strings, numbers, dates, nodes, and windows. Lastly, it lists many common JavaScript events that can be used with HTML elements like onclick, onmouseover, onkeydown, and others.

Uploaded by

Æēō Ñœē
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

PHP and Javascript Summary

The document describes various HTML elements and their attributes including images, links, lists, forms, tables, and JavaScript functions and events. It provides details on how to use common HTML elements like <img>, <a>, <ul>, <form>, and <table>. It also summarizes JavaScript concepts like loops, functions, arrays, strings, numbers, dates, nodes, and windows. Lastly, it lists many common JavaScript events that can be used with HTML elements like onclick, onmouseover, onkeydown, and others.

Uploaded by

Æēō Ñœē
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

html

image <img src="URL" ,align ,border size height width alt/>

links <a href="URL">clickable text</a>

Lists
<ul style="list-style-type:disc;"> <li> ‫<العنصر االول‬/li> <li>‫<الثاني‬/li> </ul>
<ol start=? ,type="1/A /a/I /i" > </ol>
<dl> <dt></dt> <dt></dt> </dl>
Forms

<form> <select multiple name=?(pulldown menu) size=?> </select>(scorlling menu) <input


type="checkbox,radio,submit,search,color" name=? Value=? Checked> <form/>

tables

<table border=? cellspacing=? width=?(px or %) >

<tr align=(left/center/right) , valign=(vertical top/middle/bottom ) ,rowspan=(num of rowspan) > </tr>(row)

<td></td>(cell)
</table>

javascript
(1)loops for (before loop; condition for loop; execute after loop) { what to do during the loop}
while Sets up conditions under which aloop executes do while — Similar to the while loop, however, it executes at least
once and performs a check at the end to see if the condition is met to execute again break Used to stop and exit the cycle at
certain conditions continue Skip parts of the cycle if certain conditions are met

(2)FUNCTIONS (methods)
alert() Output data in an alert box in the browser window confirm() Opens up a yes/no dialog and returns true/false
depending on user click console log() Writes information to the browser console, good for debugging purposes
document.write() Write directly to the HTML document prompt() Creates an dialogue for user input decodeURI() Decodes
a Uniform Resource Identifier (URI) createdby encodeURI or similar decodeURIComponent() Decodes a URI component
encodeURI() Encodes a URI into UTF-8 encodeURIComponent() Same but for URI components eval() Evaluates
JavaScript code represented as a string isFinite() Determines whether a passed value is a finite number isNaN() Determines
whether a value is NaN or not Number() Returns a number converted from its argument parseFloat() Parses an argument
and returns a floating point number parseInt() Parses its argument and returns an integer addeventlistener(‘click’,’function’)
arrays
concat() Join several arrays into one index Of() Returns the primitive value of/the specified object join() Combine elements
of an array into a single string and return the string last Index Of() Gives the last position at which a given element appears
in an array pop() push() Add a new element at the end reverse() shift() Remove the first element of an array slice() Pulls a
copy of a portion of an array into a new array sort() Sorts elements alphabetically splice() Adds elements in a specified way
and position to String() Converts elements to strings value Of() Returns the first position at which a given element appears
in an array
Strings
trim() //is an instruction to remove any spaces or other white spaces in the string
password_hash($pass,PASSWORD_DEFAULT) //convert the password entered by the user into a secure password
charAt() Returns a character at a specified position inside astring concat() Concatenates (joins) two or more strings into one
indexOf() Provides the position of the first occurrence of a specified text within a string lastIndexOf() search() Executes a
search for a matching text and returns its position slice() Extracts a section of a string and returns it as a new string split()
Splits a string object into an array of strings at aspecified positionsubstr() Similar to slice() but extracts a substring
depended on a specified number of characters toLowerCase() toUpperCase()
Numbers
toExponential() toFixed() Returns the string of a number with a specified number of decimals toString() abs(x)
Returnsabsolute value of x floor(x) biggest whole num <=n log(x) max(x,y,z,...,n) min(x,y,z,...,n) pow(x,y) X to the
power of y random() Returns a random number between 0 and 1 round(x) The value of x rounded to its nearest integer
sin(x) sqrt(x) tan(x) acos(x) asin(x) atan(x) cos(x) exp(x)
DATES NOW() date now
Date() Creates a new date object with the current date and time Date(2017, 5, 21, 3, 23, 10, 0) Create a custom date object.
The numbers represent year, month, day, hour, minutes, seconds, milliseconds. Date("2017-06-23") Date declaration as a
string getDate() Get the day of the month as a number (1 31) getDay() The weekday as a number (0-6) getFullYear()
getHours() Get the hour (0-23) getTime() Get the milliseconds since January 1, 1970 of 13 24 getUTCDate() setDate()
Set the day as a number (1-31) setFullYear() Sets the year (optionally month and day) setHours() Set the hour (0-23)
setTime() Set the time (milliseconds since January 1, 1970) setUTCDate() Sets the day of the month for a specified date
according to universal time (also available for day, month, fullyear, hours, minutes etc.)
Nodes
appendChild() Adds a new child node to an element as the last child node cloneNode() Clones an HTML element
compareDocumentPosition() Compares the document position of two elements hasChildNodes() isDefaultNamespace()
Returns true if a specified namespaceURI is the default isEqualNode() Checks if two elements are equal isSameNode()
Checks if two elements are the same node isSupported() Returns true if a specified feature is supported on the element
normalize() Joins adjacent text nodes and removes empty text nodes in an element removeChild() replaceChild()
getAttribute() Returns the specified attribute value of an elementnode getAttributeNode() Gets the specified attribute node
with the given namespace and name getElementsByTagName() Provides a collection of all child elements with the
specified tag name getElementsByTagNameNS() Returns a live HTMLCollection of elements with a certain tag name
belonging to the given namespace hasAttribute() removeAttribute() setAttribute() Sets or changes the specified attribute to
a specified value
Window
alert() Displays an alert box with a message and an OK button blur() Removes focus from the current window
clearInterval() Clears a timer set with setInterval() close() Closes the current window confirm() Displays a dialogue box
with a message and an OK and Cancelbutton focus() Sets focus to the current window moveBy() Moves a window relative
to its current position moveTo() Moves a window to a specified position open() Opens a new browser window print()
Prints the content of the current window prompt() Displays a dialogue box that prompts the visitor for input resizeBy()
Resizes the window by the specified number of pixels resizeTo() Resizes the window to a specified width and height
scrollBy() Scrolls the document by a specified number of pixels scrollTo() Scrolls the document to specified coordinates
setInterval() Calls a function or evaluates an expression at specified intervals stop() Stops the window from loading closed
Checks whether a window has been closed or not and returns true or false defaultStatus Sets or returns the default text in the
statusbar on a window document Returns the document object for the window frames Returns all <iframe> elements in the
current window history Provides the History object for the window innerHeight The inner height of a window’s content
area innerWidth The inner width of the content area length Find out the number of <iframe> elements in the window
location Returns the location object for the window name Sets or returns the name of a window navigator Returns the
Navigator object for the windowopener Returns a reference to the window that created the window outerHeight The outer
height of a window, including toolbars/ scrollbars outerWidth The outer width of a window, including toolbars/ scrollbars
pageXOffset Number of pixels the current document has been scrolled horizontally pageYOffset — Number of pixels the
document has been scrolled vertically parent The parent window of the current window
screen
screen Returns the Screen object for the window screenLeft The horizontal coordinate of the window (relative to screen)
screenTop The vertical coordinate of the window screenX Same as screenLeft but needed for some browsers screenY
Same as screenTop but needed for some browsers status Sets or returns the text in the statusbar of a window top Returns
the topmost browser window Screen Properties colorDepth Returns the bit depth of the color palette for displaying images
height The total height of the screen pixelDepth The color resolution of the screen in bits per pixel width The total width
of the screen

(3)events <element event=”some java script”>


onclick The event occurs when the user clicks on an element oncontextmenu User right-clicks on an element to open a
context menu ondblclick The user double-clicks on an element onmousedown User presses a mouse button over an
element onmouseenter The pointer moves onto an element onmouseleave Pointer moves out of an element onmousemove
The pointer is moving while it is over an element onmouseover When the pointer is moved onto an element or one of its
children onmouseout User moves the mouse pointer out of an element or one of its children onmouseup The user releases a
mouse button while over an element onkeydown When the user is pressing a key down onkeypress The moment the user
starts pressing a key onkeyup The user releases a key onabort The loading of a media is aborted onbeforeunload Event
occurs before the document is about to be unloaded onerror An error occurs while loading an external file onhashchange
There have been changes to the anchor part of a URL onload When an object has loaded onpagehide The user navigates
away from a webpage onpageshow When the user navigates to a webpage onresize The document view is resized onscroll
An element’s scrollbar is being scrolled onfocus An element gets focus onfocusin When an element is about to get focus
oninput User input on an element oninvalid An element is invalid onreset A form is reset onsearch The user writes
something in a search field onselect The user selects some text (for <input> and <textarea>) onsubmit A form is submitted
ondrag An element is dragged ondragend The user has finished dragging the element ondrop Dragged element is dropped
on the drop target oncopyUser copies the content of an element oncut onpaste onabort Media loading is aborted oncanplay
The browser can start playing media (e.g. a file has buffered enough) onended The media has reach its end onerror Happens
when an error occurs while loading an external file onpause Media is paused either by the user or automatically onplay
The media has been started or is no longer paused onplaying Media is playing after having been paused or stopped for
buffering onprogress Browser is in the process of downloading the media onratechange The playing speed of the media
changes onwaiting Media paused but expected to resume (for example, buffering) onmessage A message is received
through the event source onoffline Browser starts to work offline ononline The browser starts to work online ontouchmove
A finger is dragged across the screen ontouchstart Finger is placed on touch screen

jquery $(document).ready(function() {$(selector:filter).action()or event()};

$(selector).traversing method("‫)" عنصر‬.css({‫;)}الخواص الجديده‬

(1)selectors (* / #specialID /.specialClass)


(2)Filters :animated :eq(n) Select the element at index n within the matched set. :even :odd :first :last :gt(n)
greater than in the table :lt() :not() :root :hidden :visible :contains(“text”) :empty no children :has() Selects elements
which contain at least one that matches the specified selector. :parent have at least one child node :first-child :last-child
:nth-child() :only-child :checkbox :button :disabled :enabled :focus :file :image :input :password :radio :reset
:selected :submit :text

(3)events & actions bind unbind die live off on one triggerhandler undelegate blur change focus
focusin out select submit keyword keypress keyup click contextmenu dblclick mousedown mouseenter mouseleave
mousemove mouseout mouseover mouseup toggle .animate({styles},speed,easing,callback)
.clearQueue() .delay(speed,queueName) Sets a delay for all queued functions on the selected elements
.fadeIn(speed,easing(swing,linear),callback‫ الداله اللي هتتعمل تالشي‬.fadeOut() .fadeTo(speed,opacity (number
between 0.00 and 1.00 ),easing,callback) Fades in/out the selected elements to a given opacity
.fadeToggle(speed,easing,callback) ‫ التبديل بين االتنين‬.hide(speed,easing,callback) Hides the selected elements .finish
() .show() Shows the selected elements slidedown() slideUp() slideToggle() stop() toggle() Toggles between the hide() and
show() methods addclass (classname,function(index,currentclass) ) after(content,function(index)
append(content,function(index,html)insert content attr(attribute ) insert att

(4)traversing actions
add() add element to set of matched elements children()returns all direct chidren of selected element closest () return
ancestor of the ele filter find() descendant eles of ele has(0 returns all eles that has ele inside it next() sibling
ajax exchanging data with the server
variable=new XMLHttpRequest(); //create http request object

xhttp.onredystate change = function

xml.httprequest.method() or property

xhttp.open(“get”,file name,true)

xhttp.send()

(1)methods abort() cancel current reuest getResponseHeader() open(method(get or post), url(file


location) , async(true or false) , user(name), psw(pass)) :specifies the request setRequestHeader() send(string)
92Sends the request to the server

(2)Properties
onreadystatechange defines afunction to be called when readystate property changes readystate holds status of
xmlrequest (0 req not initialized/1 connection established/ 2 req received/ 3 processing req 4 req finished )
responsetext returns response data as string responsexml returns response data as xml data status return status
number of a request (200 ok/ 403 forbidden /404 not found ) statustext returns the status-text (ok.notfound

bootstrap4 grid systems (devs) that has spicific classes


(1)classes
text display-3 text-center grid(div) col-(#)/(sm/md/lg/xl-#) collumn size container row

colors .text-muted .text-primary sucsses info warning danger secondary white dark light
.bg-primary tables .table-striped .table-bordered .table-hover .table-dark .table-borderless .table-(primary sucsses info
warning danger secondary white dark light) .table-sm(small) .table-responsive image rounded .rounded-circle .img-
thumbnail .mx-auto (margin auto) .d-block(disblay block) img-fluid alert alert-(primary sucsses info warning danger )
button btn btn-(primary sucsses info warning danger secondary white dark light) outline lg(large) sm(small) blick active
disabled btn-groub -(primary sucsses info warning danger secondary white dark light) btn-groub-vertical spinner
spinner-(border grow ) text-(primary sucsses info warning danger secondary white dark light) pagenation ul active
disabled pagination-(ld sm) list groub ul active disabled list-groub-flush(remove borders) -horizontal list-group-item-
(primary sucsses info warning danger secondary white dark light) dropdown-menu dropdown-divider dropdown-
header dropdown-item active dropright dropup form form-group form-inline form-check-input form-control form-
check-inline form-control-sm-lg card(img) card-body card-title card-subtitle card-text card-link card-img-top middle
image card-img-bottom card-img-overlay list-group card-header card-footer card-group card-deck card-columns
jumbotron(div) jumbotron-fluid
php

$db = new mysqli (server-name , user-name , pass) ; // connection object-name


$stat= $db→prepare($query=INSET INTO table-name(..,..,), VALUES (?,?,?,?)); //Declare SQL query in a variable
$q = mysqli_stmt_init($dbcon);
mysqli_stmt_prepare($q, $query);
mysqli_stmt_execute($q);
exit() // closes the data base
mysqli_stmt_affected_rows($q) == 1
$result = mysqli_query ($dbcon, $query); // Run the query
SELECT CONCAT(last_name, ', ', first_name) AS name // array
mysqli_fetch_array($result, MYSQLI_ASSOC) //creates an associative array

upload_max_filesize()
$varname $arrname=array(…,..,..)
require_once(“file-name”) // include file
var = $_post[‘text-box-name’] // store data from text box into the var
define(‘constant-name’,value); //constant
class class-name{….}
class-name→attribute // accessing
class-b extends class-a {…..} // inheritance
include() function
$errors = array(); // Initialize an error array

Functions
echo print
$data=file_get_contents(“url”) get data from url to new variable
Array count() sort() isset() sizeof() isset()‫ عنصر موجود وال ال‬array_push(arrname,element)
array_search(arrname,element)‫ مكان العنصر‬array_diff (arr1, arr2)‫بيطلع المختلف بينهم‬/ unset(element) ‫بيحذف‬
‫ العنصر‬array_reverse() array_merge() array_sort()‫ترتيب بالبجدي‬

String strlen() ‫ طول‬explode(“‫”الحته اللي هيتقسم عندها‬,strname)‫ تقسم‬implode()‫تجمع‬

Date and Time date (format, timestamp) mktime (hr, min, sec, month, day, yr) strtotime (str) time ()
Standard isset(el) print(str) time() date(format, time) mt rand(min, max) header(string) die(message) include(path) JSON
json_encode(obj) json_decode(string) Session and Cookie setcookie(name, val, expiration) session_start()
session_destroy() session_regenerate_id(del ID) Cookies setcookie Sessions session_start() session_destroy()
session_cache_expire(<0-9>) session_cache_limiter() session_decode() session_encode(); session_id([])
file $fb=fopen(filename,rb/’w’) open file to read or write fhtmlspcialcharacters(fgets($fb)
file_exists(“file-name”) unlink() delet file flock() locking file $_files[‘file-name’][‘name/size/type/tem_name’] name of
the uploaded file-name/ size/type move_uploaded_file(‘$tem_name’,’$location’) copy() delet() filetype() file()

setcookie(“cookie-name”,”cookie-value”,time()+number of miliseconds//expiration data)


$_session[‘session-name’]=”session-id”

sql
create table table-name (column-name colomn-type)
insert into table-name(field1,field2,..)values(value1,value2,…)
select field1,field2,.. from table1,table2,… where condition1 and/or condition2 //fetch data from the db
update table-name set field1=new-value , field2=new-value

cluases where , like, orderd by

c#
using keyword is uesed to include namespaces in the program
datatype variablenames; //define variable
data-type [] array-name= {elements}
switch (expression){case value1: //statments break; case value2: break;}
access-modifier return-type method-name([parameters]){bodyofthemwthod}
class-name object-name = new class-name (parameter list)
puplic private protected internal protectedinternal (encapsulation)
struct structure-name {} //strctute used to represent a record kind of class not support inheritance
enum enum-name{sun,mon,tues} ; //enum is set of integers constants have the arrangment order
access-specifier class class-name {member variables, member functions} //class declaration
constructor is special function to make new objects from the class have the same name ass the class ~ destructor
class derieved-class : base-class{….} inheritance
overload : some methods with the same name different data types
abstract classname {} ; // polymorphism same method names same parameters but diffirent data types cannot make an
instance of abstract class
interface interface-name {….} //parent class contains methods donnot have parameters
namespase name{…} // used to keep set of names separte from others
try{code catch(exception name e1){code}catch(..){...}finally{...}}

(1)functions
console.readline(“”) take input from the user console.writeline(“”) string concat(..,..) contains(string value)
copy(string str) endwith() equals() toupper()
json
json.function()
localstorage.setitem(file-name,json-object) //store json object as text
localstorage.getitem(file-name) //text to java object
{“name”:”mo”} name value pair
{obj-name:{name value pair,namevalue pair}}
json_encode(obj) //php

functions stringify(obj) convert all obj elements to strings parse data from json format to javascript objecr

node js
module is like js library
exports.mydatatme=function(){instructions} // creat module thst do this instructions
var http =require(‘http’) // include http module built in module
var dt = require(‘./module-location’) include made module
http.creatserver(function(req,res){res.write(…) res.end;}) //http module makes http server that listens to server ports
res.writehead(200,{‘content-type’:’text/html}) //add http header
fs.readfile() //method to read files in the computer
fs.appendfile(filename,…..) //appends specific content to a file
fs.open(‘filename’.’w’) //openfile writes in it
fswritefile(‘file-name’,’helloworld’) // writes something in a file-name
fs.unlink(‘file-name’) // deletes spscific file
fs.rename()
require(‘url’) // include url module-l
url.parse() //return url object
require(‘upper-case’) // include upper case package
http.listen(3000) //start it up on port 3000

functions
setimeout() excute function after time delay
cleatimeout(0
setinterval()

clearinterval()
window object. function()
var st =require(“./filename”)
\console.log() console.error() console.warn()
node js package manager
-------------------------------------------------------

const http = require("http")


http.createServer((req, res) => { //create the server
//request handler code here
});
http.listen(3000) //start it up on port 3000
var myObject = { //JS object notation helps simplify definitions
myAttribute: "some value",
myMethod: function(param1, param2) {
//does something here
}
}
class AnotherClass {
constructor(p1, p2) {
this._param1 = p1;
this._param2 = p2;
}
}
myClass myObj = new myClass();
console.log("woof!");

syntax
modules functions checks
console.log(__dirname); ‫بيحدد الديركتوري اللي حطيت الكود فيها‬
‫بيديني المسار بتاع الفايل‬
console.log(__filename) ‫مكان الفايل‬
console.log(os.freemem) free memmory
console.log(os.homedir)

wordpress themes
wp_headtag () puts additional info in the head tag

You might also like