Tutorial for Opening file on File Handling in PHP

Opening file on File Handling in PHP

PHP File Handling, Create, Open, Read, Write, Append

fopen( ) – This function is used to open a file or URL.

Syntax:-

fopen(filename, mode, include_path, context)
File name – It is the name of file or url.
Mode – in which mode we want to open this file ex: – r, w etc.
Include_path – Set this parameter to ‘1’ or TRUE to specify that you want to search for the file in the PHP include path.
Context – Contexts modify or enhance the behavior of the data stream from and to files.

If the open operation fails, it returns FALSE and an error on failure.

Example:-

Tagged : / / / / /

How to use Width & Height Property in CSS?

Width & Height Property usually uses in Images, Card, fonts, tables etc… for responsive & attractive design. So, in this blog, you can learn that how can use the width & height property in CSS?

Width

This property is used to set the width of an element. We can set this property to auto and length in the form of px, cm, % etc.

Ex:-

div { width: 100px; }

Height

This property is used to set the height of an element. We can set this property to auto and length in the form of px, cm, % etc.

Ex: –

div { height: 100px; }

Tagged : / / / /

Tutorial for Basic File Handling in PHP

What is File Handling in PHP?

We can use the PHP File System to create files, read them line by line, character by character, write them, append them, delete them, and shut them. Any program requires file handling. Some tasks necessitate the processing of files. File management in PHP is comparable to how it is done in other computer languages such as C.

Basic File Handling in PHP - ExpertPHP

Which are the type of File Handling?

PHP File Handling, Create, Open, Read, Write, Append
  • Opening File
  • Reading File
  • Writing File
  • Closing File
PHP File Handling | Studytonight

Tagged : / / / / / / / /

Complete tutorial for Function in PHP

What is Function?

Function are those callable section of code that you can pass data to, and that can return data to you. Function are subprograms which are used to compute a value or perform a task.

PHP Functions Tutorial - Learn PHP Programming - YouTube

Which are the Importance of Function?

  • Easy to debug
  • Reusability
  • No code repetition
  • Easy to handle codes

How to create a Function?

Syntax:-

function function_name( )
{

Block of statement;

}
How to Define, Call & Create a function in PHP? - DevOpsSchool.com

Example:-

Some rules for creating a function:-

  • Function name only starts with a letter, an underscore ( _ ).
  • Function name cannot start with a number.
  • Do not use Predefined constant name e.g. PHP_VERSION ,PHP_OS etc.
  • Do not use reserved keywords. e.g. else, if etc.
  • Function names are case-insensitive, though it is usually good form to call functions as they appear in their declaration.

How Function Calls in code

Tagged : / / / / / / / / / / / / / / /

Top 21 Firefox Addon every software engineer must know

1.Web Developer

I absolutely recommend the ‘Web Developer‘ add-on. It gives you some great features which will make your development workflow faster. I enjoy various CSS, form, and image options. No matter if I want to check alt tags, missing images, or image dimensions, this add-on is my preferred choice.

2.Usersnap

The Usersnap Firefox add-on lets you capture and annotate any website. It works great for collecting and managing user feedback on websites or applications or for tracking bugs in your browser.

All screenshots are directly saved in your Usersnap projects. It integrates with your workflow, and you can connect Usersnap with JIRA, Trello, Slack, and 20 other project management tools. A perfect fit for QA and development teams.

3.SeoQuake

SeoQuake will help you in optimizing your web pages for search engines. It gives you a SeoBar that has loads of useful SEO-related options for you to take advantage of. This extension will assist you in identifying issues pertaining to search engine indexing in your web pages.

4.User Agent Switcher

The User-Agent Switcher allows you to switch the user agent of your browser. The add-on will add an option to the tool settings. This option lets you switch the user agent.

5.FireShot

FireShot is a Firefox add-on that creates screenshots of your web page. What is unique about this plugin is that it gives you a set of editing and annotation tools for working with your screenshots. This can be a handy extension to have for presenting your work in your portfolio.

6.Ghostery

Ghostery is a great add-on to display installed trackers and pixels of any website. It helps you to find and analyze the used marketing- and tech stack of any website. And you can block them if you don’t want your session to be recorded.

7.Firebug

Firebug is considered to be the ultimate developer’s tool for Firefox. You are given a ton of web development tools to use from within your browser. You can explore, edit, debug, and monitor CSS, HTML, and JavaScript in real-time on any web page.

8.Greasemonkey

The Greasemonkey Firefox add-on enables you to modify how a web page looks and works by using small snippets of JavaScript. There are hundreds of scripts that you can download to enhance this add-on.

9.ColorZilla

ColorZilla is an advanced color picker and eyedropper. It allows you to get the color of any pixel in the browser window. The extension also has a built-in averaging square. This helps you get a matching color to for a photo. The add-on is pretty simple and easy to use.

10.FireFTP

FireFTP is a streamlined Firefox extension for uploading files to a server. It offers several advantages to standalone FTP applications, such as its operating system-independent requirements. This browser add-on has all the features you would expect from standalone apps.

11.HTTPS Everywhere

This Firefox add-on encrypts all your communication with many major websites. As many sites support HTTPS, they still might use HTTP. Or they fill encrypted pages with links that go back to unencrypted sites. The HTTPS Everywhere add-on fixes these problems by rewriting all requests to HTTPS.

12.Palette Grabber

This add-on will build color themes that are exportable to popular graphic-editing software such as Photoshop, Paint Shop Pro, GIMP, Fireworks, and Paint.NET of the web page you’re currently viewing.

13.Total Validator

This extension is an all-in-one validation tool that will check HTML, links, take screenshots, and do a lot more. It also performs accessibility validation (WCAG, US-508), broken link checking, spell checking (in five different languages), and take screen captures via different web browsers and operating systems to see how your web pages look.

14.BuiltWith

The BuiltWith add-on analyses websites and their technologies, servers, and hosts. It works great for analyzing competitor websites and you can get insights on any web page. And it even displays tracking IDs, like the Google Analytics ID.

15.Web Developer Checklist

The Web Developer Checklist is a simple add-on that gives you an overview of the usability of your site.

16.Platypus

Hands down, Platypus is one of the best Firefox extensions for modifying a web page. It works with Greasemonkey as a sort of WYSIWYG and it will remember your edits when you visit the web page again. You can use it to experiment with different variations of a web design.

17.Dummy Lipsum

An add-on with a very simple purpose, Dummy Lipsum generates Lorem Ipsum dummy text for you to use in your designs.

18.Cookie Manager

This Cookie Manager lets you check and manage the cookies. You are able to view, add, change or even delete cookies in any of the domains. You can even export and import cookies. This is helpful to reproduce certain issues by recreating certain browser sessions.

19.Page Performance Test

It analyses web pages’ performance based on various parameters. The Page Performance Test measures network, browser, and server performance. You can use Page Performance Test directly on your console:

  1. Open up your console; you will now find a new tab “page performance”
  2. Start the performance test.

20.CSSViewer

CSSViewer allows you to inspect CSS properties on a web page that you’re viewing. It’s a great way to study styles that you’ve seen on websites to learn CSS development techniques.

21.Aardvark

Aardvark, aimed at front-end web developers, lets you select web page elements and gives you several options for them, such as removing them from the web page (great for screenshots) or modifying their colors (helpful when printing web pages).

Tagged : / / / / / / / / / / / / / / / / / / / / / / / /

HTML: Label

It defines a set of text that is associated with a particular element. <label>…..</label>

AttributeValueDescription
forelement_idSpecifies which form element a label is bound to
formform_idSpecifies one or more forms the label belongs to

element_id – The id of the element the label is bound to

Tagged : / / / / /

HTML: Text Area

A text area is a multiline text field. A user can write an unlimited number of characters in the text area.

<textarea>……</textarea>
AttributeValueDescription
autofocusautofocusSpecifies that a text area should automatically get focus when the page loads
colsnumberSpecifies the visible width of a text area
dirnametextareaname.dirSpecifies that the text direction of the textarea will be submitted
disableddisabledSpecifies that a text area should be disabled
formform_idSpecifies one or more forms the text area belongs to
maxlengthnumberSpecifies the maximum number of characters allowed in the text area
nametextSpecifies a name for a text area
placeholdertextSpecifies a short hint that describes the expected value of a text area
readonlyreadonlySpecifies that a text area should be read-only
requiredrequiredSpecifies that a text area is required/must be filled out
rowsnumberSpecifies the visible number of lines in a text area
wrapSoft(default)
hard
Specifies how the text in a text area is to be wrapped when submitted in a form
ValueDescription
softThe text in the textarea is not wrapped when submitted in a form.
hardThe text in the textarea is wrapped (contains newlines) when submitted in a form. When “hard” is used, the cols attribute must be specified
Tagged : / / / / / / / / /

Modifying Text Nodes in JavaScript

Properties

  • Data
  • Length

Methods

  • appendData(String)
  • deleteData(start, length)
  • insertData(start, string)
  • replaceData(start, length, string)
  • splitText(start)
  • substringData(start, length)

Length

Length property is used to access the length of Text which indicates the number of characters it contains.

Syntax:- TextNode.length

Data

Data property is used to set or return the value of a text node and comment node objects.

Syntax: –
Sets
TextNode.data = value
Returns
TextNode.data

Ex:- TextNode.data = “Hello DevOpsSchool”;

appendData(String)

This method is used to append the passed string to the end of the text node and comment node.

Syntax: –
TextNode.appendData(String);

Ex: –
TextNode.appendData(“Hello DevOpsSchool”);

deleteData(start, length)

This method is used to delete or remove text content from a text node and comment node. It deletes the specified length of characters starting from index defined in start.

Syntax:-
TextNode.deleteData(start, length);

Ex: –
TextNode.deleteData(0, 5);

insertData(start, string)

This method is used to insert text content to text node and comment node. It inserts the value in string, starting at the character index specified in start.

Syntax:-
TextNode.insertData(start, string)

Ex: –
TextNode.insertData(3, “Hello”)

replaceData(start, length, string)

This method is used to replace text content of text node and comment node. It inserts the value in string, starting at the character index specified in start.

Syntax:-
TextNode.replaceData(start, length, string)

Ex: –
TextNode.replaceData(0, 4, “Hello”)

splitText(start)

The splitText(start) method breaks the Text node into two nodes at the specified start index, keeping both nodes in the tree as siblings. It returns right side of the split in a new text node and leaves the left side in the original.

Syntax: –
var rightSide = TextNode.splitText(start)

Ex: –
var rightSide = TextNode.splitText(5)

substringData(start, length)

It returns the part of the current element’s (TextNode and CommentNode) text content from the specified position with the specified length.

Syntax:-
TextNode.substringData(start, length)

Ex: –
TextNode.substringData(2, 5);

Tagged : / /

Artifactory Error: file does not exist – var/etc/security/master.key

Error

$ more router-service.log
2021-08-09T06:28:34.562Z [jfrou] [INFO ] [12eb5f8f306fefda] [security_keys.go:149          ]
 [main                ] - Master key is missing. Pending for 110 seconds with 2m0s timeout
2021-08-09T06:28:39.564Z [jfrou] [INFO ] [12eb5f8f306fefda] [security_keys.go:149          ]
 [main                ] - Master key is missing. Pending for 115 seconds with 2m0s timeout
2021-08-09T06:28:44.300Z [jfrou] [FATAL] [12eb5f8f306fefda] [bootstrap.go:98               ]
 [main                ] - Failed resolving master key: failed resolving 'shared.security.mas
terKey' key; file does not exist: /opt/artifactory-pro-7.21.5/var/etc/security/master.key
[root@localhost log]#
$ more metadata-service.log
2021-08-09T06:28:44.543Z [jfmd ] [PANIC] [74b40f69b408f150] [keys.go:22                    ]
 [main                ] - Failed resolving master key: failed resolving 'shared.security.mas
terKey' key; file does not exist: /opt/artifactory-pro-7.21.5/var/etc/security/master.key
goroutine 1 [running]:
runtime/debug.Stack(0x17575f8, 0x4, 0xc000245f01)
        /src/runtime/debug/stack.go:24 +0x9f
jfrog.com/jfrog-go-commons/v7/pkg/log.(*standardLogger).Panicfc(0xc0005c5980, 0x1b1e760, 0xc
000276c60, 0xc000245f40, 0x9b, 0xc000031d98, 0x0, 0x1)
        goroot/pkg/mod/jfrog.com/jfrog-go-commons/v7@v7.21.2-m007/pkg/log/standard_logger.go
:85 +0x9e
jfrog.com/metadata/v7/services/common.MustResolveSecurityKeys(0x1b1e760, 0xc000276c60, 0x1b27070, 0xc00055b8b0
, 0x1b32910, 0xc0005c5980)
        jfrog.com/metadata/v7@v7.21.4/services/common/keys.go:22 +0x1c2
main.main()
        jfrog.com/metadata/v7@v7.21.4/metadata.go:30 +0x3b1
 [init]
$ more event-service.log
    ] - Master key is missing. Pending for 115 seconds with 2m0s timeout [startup]
2021-08-09T06:28:44.736Z [jfevt] [FATAL] [773058374c55a614] [bootstrap.go:115              ] [main
    ] - Failed resolving master key: failed resolving 'shared.security.masterKey' key; file does not exist: /o
pt/artifactory-pro-7.21.5/var/etc/security/master.key [startup]

Solution

Installed New version of Artifactory and it should solve the issues.

HTML: Form Tag

HTML forms are used to collect some data from the site visitor. The HTML <form>…..</form> tag is used to create an HTML form.

<input>
<textarea>
<button>
<select>
<option>
<optgroup>
<fieldset>
<label>
AttributeValueDescription
accept-charsetUTF-8Specifies the charset used in the submitted form (default: the page charset).
actionURLContains a URL that defines where to send the data after submitting the form
autocompleteOn (default)
Off
Determines that the browser retains the history of previous values.
enctype (default: is url-encoded)specifies how the browser encodes the data before it sends it to the server.
methodGET (default)
POST
Specifies how to send the form data to a web server. The data can be sent as URL variables, by using the get method or as HTTP post, by using the post method
namenameSpecifies a name used to identify the form
novalidatenovalidateSpecifies that the browser should not validate the form.
target_self (default)
_blank
_parent
_top
framename
Specifies the target of the address in the action attribute

Input Tag

<input> tag prompts the user to enter data and also request for the information from the web server after submitting the web form.

<form>
	<input>
</form>
No input end tag in HTML5
AttributeValueDescription
acceptfile_extension
audio/*
video/*
image/*
media_type
Specifies the types of files that the server accepts
alttextSpecifies an alternate text for an image. only used with type=“image”
autocompleteon
off
It enables or disable autocomplete in <input> tag
autofocusautofocusSpecifies that an <input> element should automatically get focus when the page loads
checkedcheckedInput element should be checked/selected when a web page loads. It is used only with  type=”checkbox” and type=”radio”
dirnameinputname.dirSpecifies that the text direction will be submitted
disableddisabledDisables the input element when it loads on the client side’s web page, so that user cannot write text in it or select it. This attribute cannot be used with type=“hidden”
formform_idSpecifies form’s id to which the input field belongs.
formactionURLSpecifies the URL of the file that will process the input control when the form is submitted
formenctypeapplication/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how the form-data should be encoded when submitting it to the server
formmethodGET
POST
Defines the HTTP method for sending data to the action URL
formnovalidateformnovalidateDefines that form elements should not be validated when submitted
formtarget_blank
_self
_parent
_top
framename
Specifies where to display the response that is received after submitting the form
heightpixelsIndicates the height of an input field
listId of a datalistContains the id of the <datalist> tag where a datalist element contains various options for an input field
maxnumber
date
Specifies the maximum value for an <input> element
number, range, date, datetime-local, month, time and week.
maxlength
minlength
numberSpecifies the maximum/minimum number of characters allowed in a text field.
minnumber
date
Specifies a minimum value for an <input> element
number, range, date, datetime-local, month, time and week.
multiplemultipleIndicates whether the user is allowed to enter more than one value
nametextDefines a unique name for the input element.
patternregexpSpecifies a regular expression that an <input> element’s value is checked against
placeholdertextSpecifies a short hint that describes the expected value
text, search, url, tel, email, and password
readonlyreadonlyIndicates that the value of this field cannot be modified.
requiredrequiredSpecifies that an input field must be filled out before submitting the form
sizenumberSpecifies the width of the control. If type=”text” or type=”password” this refers to the width in characters. Otherwise it’s in pixels.
srcURLDefines the URL of the image to display. It can be used only with type=“image”
stepnumberSpecifies the legal number intervals for an input field
typebutton
checkbox
color
date 
datetime 
datetime-local 
email 
file
hidden
image
month 
number 
password
radio
range 
reset
search
submit
tel
text
time 
url
week
Indicates the type of the input element. The default value is text.
valuetextSpecifies the value of an <input> element
widthpixelsIndicates the width of an input field

Type Attribute

It indicates the type of input element. It’s an empty tag. The default value is text.

Ex: –

<input> 
<input type=“text”>
  • Text – It defines a single-line text field. <input type=“text”>
  • Password – A password field is like text field, the difference being that this control hides each typed character by displaying an asterisk(*) or bullets(●) instead of the character itself. <input type=“password”>
  • Button – This is used to add a button on a web form to activate a script when an user click the button. <input type=“button”>
  • Email – This field is used to add an email address or a list of email address to a form, where type=“email” is a value for the input type. The input format should be an email like example@gmail.com else it will prompt an error. <input type=“email”>
  • Check Box – A check box is a small box, which when selected includes a checkmark. It is used to allow the user to select one or more than one of the options available on a web page. An User can select or clear the check box by clicking it. <input type=“checkbox”>
  • Radio Button – A radio button is used to create a series of options of which only one can be selected. It is displayed as a circle which when selected, displays a dot in the middle. <input type=“radio”>
  • •URL – The URL field is used to enter only the web addresses, in their correct format. If the URL is not entered in the correct format then the URL field validates the text field to enter web address. <input type=“url”> Autofocus – helps in keeping the focus of mouse pointer on the input field. Pattern – defines the regular expression of the text that should be entered in the text field.
  • Search Box – This is used to add a search box to a form. <input type=“search”>
  • Tel – The tel type represents a one-line plain-text edit for entering a telephone number. <input type=“tel”>
  • Range – Range input represents the input of limited range numerical values. <input type=“range”>
  • Number – Number is used to validate the textbox only if the value within the field is a numerical value. <input type=“number”>
  • File – This is used to upload a file on a web page. You also need to set the enctype=“multipart/form-data”. <input type=“file”>
  • Image – It represents either an image from which the UA enables a user to interactively select a pair of coordinates and submit the form, or alternatively a button from which the user can submit the form. <input type=“image”>
  • Hidden – A hidden control stores the data that is not visible to the user on a web page. This control is used to submit some information, which can not be edited by user. <input type=“hidden”>
  • Submit – A submit button is used to transfer form data to the URL specified in the <form action> tag.<input type=“submit”>
  • Reset Button – A reset button helps user to clear all the data that they have entered in the text fields.<input type=“reset”>
  • Date – This is used for input fields that should contain a date. <input type=“date”>
  • Time – It allows the user to select a time. <input type=“time”>
  • DateTime – It allows the user to select  date and time. <input type=“datetime”>
  • Datetime-local – It allows the user to select a date and time. <input type=“datetime-local”>
  • Month – It allows the user to select a month and year. <input type=“month”>
  • Week – It allows the user to select a week and year. <input type=“week”>
  • Color – It is used for input fields that should contain a color. <input type=“color”>

accept-charset Attribute

It specifies the character encodings that are to be used for the form submission.

ISO-8859-1 Character encoding for the Latin alphabet

UTF-8 Character encoding for Unicode

<form accept-charset=“UTF-8”>

Action Attribute

It contains a URL that defines where to send the data after submitting the form. It specifies the physical address of the server to which the user data should be redirected at the click of the submit button. action=http://www.something.com/something.html action=“page.html” action=“gotform.php” action=“example.asp”

If the action attribute is omitted, the action is set to the current page.

Autocomplete

On – The browser will automatically complete values based on values that the user has entered before. Off – User need to write all values each time they fill the form <form autocomplete=“on”>

enctype Attribute

It specifies how the browser encodes the data before it sends it to the server.

ValueDescription
application/x-www-form-urlencodedAll characters are encoded before sent (spaces are converted to “+” symbols, and special characters are converted to ASCII HEX values)
multipart/form-dataNo characters are encoded. This value is required when you are using forms that have a file upload control
text/plainSpaces are converted to “+” symbols, but no special characters are encoded
<form enctype=“multipart/form-data”>

Method Attribute

It Specifies how to send the form data to a web server. The data can be sent as URL variables, by using the get method or as HTTP post, by using the post method.

  • GET(default)
  • POST

GET

GET sends the data as part of the URL.

  • Appends form-data into the URL in name/value pairs.
  • The length of a URL is limited 2048 characters.
  • Never use GET method if you have password or other sensitive information to be sent to the server.
  • Useful for form submissions where a user want to bookmark the result.
  • GET is better for non-secure data, like query strings in Google.
  • GET can’t be used to send binary data, ex:-  images or word documents.
<form action=“some.php” method = “GET”>

If we use an invalid value for the method attribute of the <form> tag, the browser will use the default value GET.

POST

HTTP POST requests supply additional data from the client (browser) to the server in the message body.

  • Appends form-data inside the body of the HTTP request (data is not shown is in URL).
  • The POST method does not have any restriction on data size to be sent.
  • Form submissions with POST cannot be bookmarked.
  • The POST method can be used to send ASCII as well as binary data. Ex:-  image and word documents etc.
  • The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.
  • POST is a little safer than GET because the parameters are not stored in browser history or in web server logs.
<form action=“some.php” method = “POST”>
GETPOST
BACK button/ReloadHarmlessData will be re-submitted (the browser should alert the user that the data are about to be re-submitted)
BookmarkedCan be bookmarkedCannot be bookmarked
CachedCan be cachedNot cached
Encoding typeapplication/x-www-form-urlencodedapplication/x-www-form-urlencoded or multipart/form-data. Use multipart encoding for binary data
HistoryParameters remain in browser historyParameters are not saved in browser history
Restrictions on data typeOnly ASCII characters allowedNo restrictions. Binary data is also allowed
VisibilityData is visible to everyone in the URLData is not displayed in the URL

Name  Attribute

Specifies a name used to identify the form. It is Used to give a name to the control which is sent to the server to be recognized and get the value. name=“lastname”

novalidate

If we use novalidate attribute in form tag then the validation will not take place, even if there is a required filed.

<form novalidate>
<form novalidate=“novalidate”> 
<form novalidate=“true”> 

There is one more tag formnovalidate which is used by input tag to speficiy novlidate this particular text or field we will study about this later.

Text Direction (dirname)

Specifies that the text direction will be submitted

ValueDescription
ltrDefault. Left-to-right text direction
rtlRight-to-left text direction
autoLet the browser figure out the text direction, based on the content
<input type=“text” name=“city” dirname=“city.dir”>

Min and Max

number, range, date, datetime-local, month, time and week.

Tagged : / / / / / / / / / / / / / /